mixing managed code with native code

  • Thread starter Thread starter rhossi
  • Start date Start date
R

rhossi

I have an Assembly using IJW that uses a third party native library.
There are quite a few function calls that uses callbacks and pointers.

One of those takes a delegate: bool enumXXX(char * someData, unsigned
long lparam);

Inside the passed delegate I need to cast from unsigned long to
List<String^> ^. How Can I do this ?

Thanks,

Felipe Garcia
 
rhossi said:
I have an Assembly using IJW that uses a third party native library.
There are quite a few function calls that uses callbacks and pointers.

One of those takes a delegate: bool enumXXX(char * someData, unsigned
long lparam);

Inside the passed delegate I need to cast from unsigned long to
List<String^> ^. How Can I do this ?

You can't pass a tracking handle/reference through a native API, because the
GC could move it meanwhile. Use a pinned pointer instead.

Note that your code won't be 64-bit clean if it uses an unsigned long
variable to hold a pointer.
 
Back
Top