End Google Ads 201810 - BS.net 01 --> I would like to copy the data content of pDataByte to QByte using Microsoft Visual C++ 2008 .NET

Debug Info

Name Value Type
pDataByte {System.Array} System::Object^
[0x0] 0x41 ‘A’ unsigned char
[0x1] 0x42 ‘B’ unsigned char
[0x2] 0x43 ‘C’ unsigned char
[0x3] 0x44 ‘D’ unsigned char

QByte {Length=0x4} unsigned char[]
[0x0] 0x00 ‘’ unsigned char
[0x1] 0x00 ‘’ unsigned char
[0x2] 0x00 ‘’ unsigned char
[0x3] 0x00 ‘’ unsigned char


I have tried several approaches, for example:


//Declare variables
System::Object ^pDataByte;
unsigned char QByte[4];

//External DLL Function
ReadOutput(pDataByte);

//Current variable status see “Debug Info”

//Copy values to local variable
QByte[0] = (unsigned char)System::Convert::ToChar(pDataByte);


Error Code (at runtime at line: QByte[0] = (unsigned char)System...)
An unhandled exception of type 'System.InvalidCastException' occurred in mscorlib.dll
Additional information: Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'.


Please help, I have tried very hard to get this to work, I am used to plane C++ (not .NET Framework)