This question indicates that it is possible for a 32-bit COM client to talk to a 64-bit COM server (and vice-versa), provided the server is out-of-process. I'm trying to implement a client using the Java Com Bridge (JaCoB) library to talk to a third-party out-of-process server in this manner, which should be possible according to this question. The test code I'm using succeeds if I match the process architectures (32-bit to 32-bit or 64-bit to 64-bit), but fails for any cross combination with this exception:
Exception in thread "main" com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: Execute
Description: Invalid callee.
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:858)
at com.jacob.com.Dispatch.callN(Dispatch.java:455)
at com.jacob.com.Dispatch.call(Dispatch.java:544)
at com.jacob.activeX.ActiveXComponent.invoke(ActiveXComponent.java:447)
...
Any ideas?
Update
After debugging the exception I'm fairly certain the underlying COM error is DISP_E_BADCALLEE. After some web digging I discovered a possible cause is an invalid method signature, so here are some more details. The COM server is MATLAB, and I am trying to call the Execute
and Quit
methods. Here are their COM type signatures (from OLEView):
BSTR _stdcall Execute([in] BSTR Name);
void _stdcall Quit();
And here is my test code:
public static void main(String[] args) {
ActiveXComponent ml = new ActiveXComponent("Matlab.Application.Single.7");
System.out.println(ml.invoke("Execute","version"));
ml.invoke("Quit");
ml.safeRelease();
}
In our application we currently use Com4J for COM Control Access, but we noticed that some ActiveX controls have poorly implemented dispatch functions (if I understood this correctly), so we have to choose for each control if we use:
or, for OLE embedding
I worked with Jacob before, but it seemed to be very unstable (at least for the ActiveX controls I tried some time ago).