Jacob: com.jacob.com.ComFailException: Can't co-create object

回眸只為那壹抹淺笑 提交于 2019-12-12 02:48:58

问题


I am facing exception Exception in thread "main" com.jacob.com.ComFailException: Can't co-create object while running the code below.

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.

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.


回答1:


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.

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:


I had the same problem and this is how I fixed it:

  1. Find your COM object using OLE/COM object Viewer
  2. Make sure to register your dll with regsvr32.exe (from C:\Windows\System32)
  3. 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/



回答3:


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.

import com.jacob.activeX.ActiveXComponent;

ActiveXComponent activeXComponent = new ActiveXComponent("ACTIVEX.ActiveXCtrl.1");


来源:https://stackoverflow.com/questions/23951145/jacob-com-jacob-com-comfailexception-cant-co-create-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!