Java 雅各布:com.jacob.com.ComFailException:无法共同创建对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23951145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jacob: com.jacob.com.ComFailException: Can't co-create object
提问by Shonali
I am facing exception Exception in thread "main" com.jacob.com.ComFailException: Can't co-create object
while running the code below.
我Exception in thread "main" com.jacob.com.ComFailException: Can't co-create object
在运行下面的代码时遇到异常。
I checked online for help. Some sites say that I need to register my dll. I tried registering using regsvr32.exe
. But I am unable to register successfully. Getting below popup.
我上网查了下求助。有些网站说我需要注册我的dll。我尝试使用regsvr32.exe
. 但是我无法成功注册。在弹出窗口下方。
The module "jacob-1.18-M2-x64.dll" was loaded but the entry-point DllRegisterServer was not found.Make sure that "jacob-1.18-M2-x64.dll" is a valid DLL or OCX file and then try again.
模块“jacob-1.18-M2-x64.dll”已加载,但未找到入口点 DllRegisterServer。请确保“jacob-1.18-M2-x64.dll”是有效的 DLL 或 OCX 文件,然后重试.
回答by piet.t
1.) You don't need to register the jacob-dll, it just has to be somewhere on your java.library.path. It is the dll that contains the COM-object that has to be registered.
1.) 你不需要注册 jacob-dll,它只需要在你的 java.library.path 的某个地方。它是包含必须注册的 COM 对象的 dll。
2.) If the COM-dll is registered you have to take care to use the correct JVM with the library. 32-bit-dlls will work only with a 32-bit-JVM, 64-bit-dlls only with a 64-bit-jvm. Using the wrong JVM will result in the Can't co-create object
error.
2.) 如果 COM-dll 已注册,您必须小心使用正确的 JVM 和库。32 位 dll 仅适用于 32 位 JVM,64 位 dll 仅适用于 64 位 jvm。使用错误的 JVM 会导致Can't co-create object
错误。
回答by Adrian Muntean
I had the same problem and this is how I fixed it:
我遇到了同样的问题,这就是我解决它的方法:
- Find your COM object using OLE/COM object Viewer
- Make sure to register your dll with regsvr32.exe (from C:\Windows\System32)
- You need to make a surrogate in order to access a 32-bit dll from a 64 bit app. See this here : http://www.gfi.com/blog/32bit-object-64bit-environment/
- 使用 OLE/COM 对象查看器查找您的 COM 对象
- 确保使用 regsvr32.exe 注册您的 dll(来自 C:\Windows\System32)
- 您需要进行代理才能从 64 位应用程序访问 32 位 dll。在这里看到这个:http: //www.gfi.com/blog/32bit-object-64bit-environment/
回答by cosmosjefry
I encounted same problem and solved like following this. 1.Set lib path of jacob.jar 2.Copy jacob-x86.dll(or 64bit case jacob-x64.dll) to System32 directory.
我遇到了同样的问题并像下面这样解决了。1.设置jacob.jar的lib路径 2.复制jacob-x86.dll(或64位情况jacob-x64.dll)到System32目录。
import com.jacob.activeX.ActiveXComponent;
ActiveXComponent activeXComponent = new ActiveXComponent("ACTIVEX.ActiveXCtrl.1");