passing an array of structures from C# to C++ using IntPtr
I have a structure -->
public struct readers
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1000)]
public IntPtr[] tag_list;
};
Marshalling has to be done in between "IntPtr[] tag_list" & structure
TAG_IN_PARAM
[StructLayout(LayoutKind.Sequential)]
internal struct TAG_IN_PARAM
{
public int vis_cnt;
public bool valid;
}
Also its an array as => TAG_IN_PARAM[] tag_list = new TAG_IN_PARAM[1000];
I want to pass structure "readers" from C# to C++ DLL. However, i have
been doing marshalling but garbage value is coming on DLL side.
// allocating memory Marshal.StructureToPtr(tag_list[j],
Reader.tag_list[j], false);
OR IF ANY OTHER WAY I CAN DO IT, PLEASE CONVEY. Any help would be
appreciated. Thanks in Advance.
No comments:
Post a Comment