I have an unmanaged DLL with a function that takes a pointer as an argument. How do I pass a pointer from C# without being 'unsafe'?
Here's some example code:
[DllImport(@"Bird.dll")]
private static extern bool foo(ushort *comport);
The corresponding entry in the header:
BOOL DLLEXPORT foo(WORD *pwComport);
When I try and simply dereference it (&comport
), I get an error saying: "Pointers and fixed size buffers may only be used in an unsafe context."
How do I work around this?