i have a function in c++ com that gets an unsigned char *buffer parameter.
when i use the dll in c# this function expects 'ref byte' parameter.
how do i pass a byte buffer as a parameter to the c++ function and receive it as an unsigned char *buffer in the c++ function ?
* already tried IntPTR , the compiler write that it cant convert system.Intptr to ref byte.
fixed (byte* p = buf)
IntPtr MyIntPtr = (IntPtr)p;
Ralfeus wrote: Thanks :-)
I'm also wondering about another thing. Both my projects - C# and C++ - are for .net. I guessed the interoperation between two managed projects should be more simple. At least .net types should be understood by any language. Am I wrong?
You are not wrong. If you make a managed c++/c#/vb.net class library you can reference it and use it from other languages.
I am using the same kind of functions. I am able to compile successfully, but at runtime there's "System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt". Did you encounter same problem?
Here are C++/C# function:
C++: Scan(char* List);
C# equivalent: Scan(ref byte List);