I created 2 programs - in C # and C ++, both called my own methods from the C dll. C ++ works fine because there are the same data types; C # does not work.
And the native parameter of the unsigned char* function. I tried byte[] in C #, this did not work, I tried:
fixed(byte* ptr = byte_array) { native_function(ptr, (uint)byte_array.Length); }
It also does not work. Is it correct to convert byte array to byte* this way? Is it correct to use bytes in C # as an unsigned char in C ?
EDIT: This stuff returns the wrong result:
byte[] byte_array = Encoding.UTF8.GetBytes(source_string); nativeMethod(byte_array, (uint)byte_array.Length);
This material also returns an incorrect result:
byte* ptr; ptr = (byte*)Marshal.AllocHGlobal((int)byte_array.Length); Marshal.Copy(byte_array, 0, (IntPtr)ptr, byte_array.Length);
source share