Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The structure in C++ and C# is as follows. Marshaling, packing, and DllImport of byte[] in C# are difficult. help.
C++
[c++]
struct TInfo
{
double Rate;
double Depth;
unsigned char* Img;
}

extern "C" __declspec(dllexport) void SetInfo(TInfo _info);

[c#]
public struct TInfo
{
public double Rate;
public double Depth;
public byte[] Img;
}
[DllImport("CPPDLL.dll", CallingConvention = CallingConvention.Cdecl)]
void SetInfo(TInfo _info);


What I have tried:

Marshaling, Pack=1 in c# and cdecl in c++
Posted
Updated 27-Nov-23 14:39pm
v2
Comments
Member 12195616 27-Nov-23 18:06pm    
It tells you how to pack and deliver in C# (.exe) and how to receive it in C++(.dll)

1 solution

 
Share this answer
 
Comments
CPallini 28-Nov-23 2:06am    
5.
Maciej Los 29-Nov-23 6:09am    
5ed!

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