Seems I accidentily posted this in open Discussion first, so now I'll go the more appropriate help topic.
I have a C# object, interface is something like void print(string[] names) which is available via COM interop, but I am not sure how to pass the arguments from Java. I've tried many things and get core dump from the jacob JNI code, or else all sorts of type errors. What should I be doing in the Java? I am using Jacob-1.14.3.
Jay Walters
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is the type of exception I'm getting. I've gotten different but similar ones depending if I try to pass a SafeArray through myself or let Jacob create one.
Exception in thread "main" com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: print
Description: Type mismatch.
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)
Thanks for your help
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I have a propery called QuoteCode which I have to set. But this property is an array. In VB it's QuoteCode(0) = "101". But when I try with activeXComp.setProperty("QuoteCode", "101") I get a "Parameter not optional" Exception. Do you have any ideea about how to do this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Seems I accidentily posted this in open Discussion first, so now I'll go the more appropriate help topic.
I have a C# object, interface is something like void print(string[] names) which is available via COM interop, but I am not sure how to pass the arguments from Java. I've tried many things and get core dump from the jacob JNI code, or else all sorts of type errors. What should I be doing in the Java? I am using Jacob-1.14.3.
Jay Walters
This is the type of exception I'm getting. I've gotten different but similar ones depending if I try to pass a SafeArray through myself or let Jacob create one.
Exception in thread "main" com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: print
Description: Type mismatch.
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)
Thanks for your help
Managed to get it all figured out.
for c#
void print(string[] names)
the call from java is
SafeArray sArray = new SafeArray(Variant.VariantString, 2);
sArray.fromStringArray(new String[] { "Foo", "Bar" });
Variant vt = new Variant();
vt.putSafeArrayRef(sArray);
loader.call(loader, "print", vt);
Seems a bit cumbersome, but it works.
Hello, I have a propery called QuoteCode which I have to set. But this property is an array. In VB it's QuoteCode(0) = "101". But when I try with activeXComp.setProperty("QuoteCode", "101") I get a "Parameter not optional" Exception. Do you have any ideea about how to do this?