Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1033
  • Last Modified:

serialization of native C++ object , deserialization of the same object at C# side

I have a C++ ActiveX control, which has a method GetEntity().
This method must return an Entity object (which is a bag of string-int properties, to keep things simple).
This method is called by C# application.

Question: how do you pass the object *by value* from C++ code to C# code?
We can assume that both worlds have a definition of an object, and to pass it means to fill fields in C# object by values in C++ object.

I cannot create COM exposed entity and call its method from C# code to retrieve single values because of bad performance of this .

At the moment I am using custom serialization mechanism, which is part of object interface, dumping self to the bit stream, which is then passed as a return value from ActiveX method. C# code then deserializes the stream to the object. This solution is hard to maintain and it is too bulky.

Do you have any other ideas?
0
Clarity_Telephony
Asked:
Clarity_Telephony
1 Solution
 
Daniel JungesCommented:
see at: http://www.codeproject.com/KB/cs/OpenNxSerialization.aspx
he explains the native serialization.
0
 
SunnyDarkCommented:
You can use Marshal.PtrToStructure
"Marshals data from an unmanaged block of memory to a managed object. "

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now