Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Holder parameters not supported for IDispatch methods #14

Open
quipsy-hamberger opened this issue Feb 25, 2013 · 5 comments
Open

Holder parameters not supported for IDispatch methods #14

quipsy-hamberger opened this issue Feb 25, 2013 · 5 comments

Comments

@quipsy-hamberger
Copy link

com4j.ComException: 80020005 Invocation failed: (null) : Type conflict. : .\com4j.cpp:82

I am getting this exception when running com4j. I am totally stuck. Can someone give me advice how to go on?

The TLB looks like this:

    [id(0x00000003)]
    long InitMesswertkanal(
                    [in] long* lKanalHandle, 
                    [in] BSTR lPruefmittel, 
                    [in] BSTR strPruefauftrag, 
                    [in] BSTR strMerkmal, 
                    [in] BSTR strSensorverknuepfung, 
                    [in] short nMesswertberechnung, 
                    [in] long hWnd);

And here is what com4j wraps:

@DISPID(3)
int initMesswertkanal(
Holder lKanalHandle,
java.lang.String lPruefmittel,
java.lang.String strPruefauftrag,
java.lang.String strMerkmal,
java.lang.String strSensorverknuepfung,
short nMesswertberechnung,
int hWnd);

Thanks!
-Ralf

@mpoindexter
Copy link
Collaborator

Looks like com4j does not handle Holder arguments to IDispatch methods (arguments to an IDispatch method must be variants, and com4j does not currently know how to turn Holders into Variants). If the interface is a dual, then you could try using the non-IDispatch version.

@mpoindexter
Copy link
Collaborator

If anyone is interested in producing a patch for this: Looks like at a minimum you would have to add support for Holders in native/variant.cpp:convertToVariant() (starts at line 253)

@JamaraCP
Copy link

I'm having the same problem when I trying to access the VaxSIPUserAgentOCX. I obtain the COMObject, but when I call a method (any method) get the error. I not understand the yours answers and I not know C/C++/C#. Could you explain me better?

StackTrace:
"... 8000ffff Invocation failed: (null) : Catastrophic failure : .\com4j.cpp:82
at com4j.Wrapper.invoke(Wrapper.java:166)
at com.sun.proxy.$Proxy5.setLicenceKey(Unknown Source)
at exercc.testeCOM.main(testeCOM.java:32)".

This is the method in the interface:
@DISPID(2)
boolean setLicenceKey(
java.lang.String licenceKey);

I generate a .IDL in the oleview:

[id(0x00000002)]
VARIANT_BOOL SetLicenceKey(BSTR LicenceKey);

Any help is very wellcome!
Thanks in advance.

@mpoindexter
Copy link
Collaborator

This is not the same error as above. It comes from the same source line (com4j.cpp:82) because that is the line that catches any errors on the native side of things and translates it to a Java exception.

I do not know what the problem is in your specific instance. It could be a problem with your IDL, a bug in COM4J, a problem in the code you are calling, or incorrect arguments you are passing. Since this is not the same issue, a better place for this question would be the COM4J users mailing list. Given the current activity level on COM4J I wouldn't expect much of a response unfortunately. Sorry to be so unhelpful.

@JamaraCP
Copy link

Thank you, honestly. You're the first person to answer me.
Here's my method call:

testVax2.wsh._DVaxSIPUserAgentOCX test = (testVax2.wsh._DVaxSIPUserAgentOCX) ClassFactory.createVaxSIPUserAgentOCX();
String key = "Here I insert the license key";
System.out.println("test ("+test+")");
test.setLicenceKey(key); //here the error occurs

It passes a Hex String as argument, that's all. I checked that the bstr type is similar to a String, and the argument from Java IS a String. Could it be the argument, then? It looks like the same type to me. I don't know. I followed the tutorial on http://com4j.java.net/. Sounds easy, it's a simple call, but I can't figure out that error. I've been reading about annotations and the COM4J structure, but it didn't help much. Have you ever used com4j with ocx from third parties? Do you have any example you could show me?
I'll change topics, as you said. You can answer me there, if you wish to do so.

thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants