Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my C++ cli program, I reference a .NET C# DLL and call some APIs inside.
One of the API interface is Byte[], I pass C++Cli Byte array but get an error..
how should I input a byte array to C# API?

Here is my code:

//Here is C++ Cli code:
XML
void PassData(array<Byte>^ ArrayData)
{
    //get compiler error here:
    CSharpDLL.PassData(ArrayData);
    return;
}
Posted
Comments
Richard MacCutchan 10-Nov-14 8:43am    
That's not a Byte[] it's an array object, which is something totally different. You should check if the array class contains a method to convert its content to a simple Byte[].

1 solution

in C++ use a real memory buffer and in c# use byte[]. Take care to make in every environment o own copy of the data.

Here is good looking code on social.msdn.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900