Reputation: 1750
I have a DLL, which I cannot change but was written in C++. It is calling a function in my managed C# DLL (which I am free to change). There are a lot of parameters which need to be passed but some work and some dont.
There is no problem passing along an "unsigned char*", but there is a problem passing an "unsigned int*" or an "int".
When the C++ DLL sends an int* I try to catch it in my C# DLL with a "uint*". I get a compiler error saying cannot convert parameter from "int*" to "long*".
I have tried all sorts of UInt16, ushort etc, but I always get similar errors.
How do I marshal this pointer array into my program?
Upvotes: 1
Views: 1239
Reputation: 371
I agree with Davide on the IntPtr. You need to have the parameter read as an IntPtr. After the Interop is complete you can then do a MyIntPtr.ToInt32() or whatever conversion you might like.
Upvotes: 0
Reputation: 44605
did you try with IntPtr ? I believe it can be used for Handles and also for pointers to integers.
Upvotes: 1