Passing a Structure to C++ API using Marshal.StructureToPtr in C#
问题 I am using API written in C++ in my code (writting in C#). API requires a parameter as Pointer to Structure. The Structure consists of "Int"s and Char Arrays: for example unsafe public struct ToBePassed { Int32 Num1; Int32 Num2; Char[] Data; // or fixed Char Data[255]; } I can not directly pass the structure pointer to API because in that case, I am getting error as "Pointers cannot reference Marshaled structures". Code get compiled successfully but this Error comes when I execute (Debug) the