• Advertisement
Sign in to follow this  

[c# to c++]send array of structures

This topic is 595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello.
I would send some array of primitive structures from c# to c++.
1)marshaling
2)cli c++ .net dll wrapper
3)?other technology

what are the pro and cons?
only a base Then I do an full search on google.
thanks.

Share this post


Link to post
Share on other sites
Advertisement

Depending of your project the answer o this mayvary. Lets assume you have a c++/cli project then doing this would be simpler than with c++ itself where marshalling (and also other c++/cli related technics) may cause some production overhead.

Lets assume you are plain c++ then you could serialize you structs if they are such simple as you say. A related function would look like this
 

__declspec(dllexport) void GetStructArray(byte* toCopyTo)
{
   //write your serializer code here
}

and on your c# side you'll do

[DllImport("Your.dll")]
public static extern void nativeGetStructArray
(
    [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]
    byte[] data
}

and deserialize them after you got them

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement