My Header file.
extern "C" class MyFuncs
{
public:
__declspec(dllexport) unsigned char PassImage(unsigned char buffer, int size);
};
CPP file.
unsigned char MyFuncs::PassImage(unsigned char buffer, int size)
{
return buffer;
}
All works well except when i am returning buffer back to my main application.
[DllImport("ExampleDLL.dll", EntryPoint = "?PassImage@MyFuncs@Funcs@@QAEXEH@Z")]
public static extern byte[] PassImage(byte[] a, int count);
The error occurs when i am return unsigned char to byte[].
If i change byte[] to byte i get a value back an no error.
This is the exact error:
Cannot marshal 'return value': Invalid managed/unmanaged type combination.
How can I accept back unsigned char to byte[]?
unsigned char
, you can't return abyte[]
like that. – David Heffernanbyte[]
like that. What we need to understand is what you are trying to do. You also need to get on top of whatunsigned char
is. It is a single scalar. It's not an array. Oh, and you also have an instance method which is not good too. So, it's just a total mess at the moment. You need to step back, go more slowly, think more deeply. Thrashing around won't get you anyway. Seek understanding. – David Heffernan