Dave said:
You are welcome.
I've used PInvoke on straight non-class-based
DLLs so I'm clear on that, but I was wondering how a class object
inside that DLL would be...:
1: Accessed (function-wise) via PInvoke.
Straight to the crux of the issue.
With IJW, you don't need to use
P/Invoke.
What I did was to create a .Net proxy class with one public method for every
method of the native class.
The constructor of my managed class uses IJW to call a native function which
creates an object of the native class. That native function just invokes the
constructor straight-away. I save a pointer to that native object as a
private member of .Net class.
Every public method of the .Net class uses IJW to call a native stub to
marshall arguments and to call the corresponding native method of the object
using the saved pointer. After the call to the native method returns, any
result is unmarshalled back to managed code.
In my case I was adapting some stuff of mine to accomodate the .Net
platform. And since I developed both the native and managed sides of this
application, I didn't need to worry about the name mangling issues that
arise when you try to export a class based interface across a DLL boundary.
If that's a concern for you, then you'd be better off with flattening the
exported interface or using COM.
Regards,
Will