I have to use external native library which expect to get a Java object instance, then it calls some method at this instance.
Java method signature:
public static native int Msg_StartUp(String functionName, boolen, boolean, Object callBackObj);
My version of C# method:
public static extern int Msg_StartUp(String functionName, bool, bool, Object callBackObj);
It is kind of callback registration, "functionName" should contains method which is called by native library.
When I call this method I receives exceptions:
System.Runtime.InteropServices.MarshalDirectiveException: Type Java.Lang.Object which is passed to unmanaged code must have a StructLayout attribute.
When I change
Object parameter types to
JValue and call with
new JValue(JNIEnv.ToJniHandle(obj)), I get System.NullReferenceException exception.
I browsed manuals and forums but I didn't find similar case.
Probably I will be able to resolve this problem with extra Java code and then use JNI or Java Bindings Library but I'm looking for simpler solution.
Did anybody meet with similar case or know correct solution ?