Connect 64bit Java with 32bit COM dll using Com4j or Jacob

◇◆丶佛笑我妖孽 提交于 2019-12-01 10:34:16

This won't work because the bitness of your client process and COM DLL don't match. When trying to create a new instance, CoCreateInstance tries to find related class information in the 64-bit hive of the registry. This fails because its actually located in the 32-bit hive, where you registered the DLL.

To remedy this, you have the option of using a surrogate process, which allows your CoClass to be instantiated in a distinct native process. Your client can then communicate with the surrogate via IPC (see here for further info).

As a quick start, you can mark your CoClass as a candidate for the default dllhost.exe surrogate process: OLE/COM Object Viewer (x86) as Admin > All Objects > [Your CoClass] > Implementation > Use Surrogate Process (leave path empty).

If you intend to distribute your application, you may place this information in a REG script or import your DLL into a COM+ server application.

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