Solved

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

Posted on 2007-11-29
3
1,001 Views
Last Modified: 2013-11-06
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
Comment
Question by:Clarity_Telephony
3 Comments
 
LVL 14

Accepted Solution

by:
Daniel Junges earned 500 total points
Comment Utility
see at: http://www.codeproject.com/KB/cs/OpenNxSerialization.aspx
he explains the native serialization.
0
 
LVL 8

Expert Comment

by:SunnyDark
Comment Utility
You can use Marshal.PtrToStructure
"Marshals data from an unmanaged block of memory to a managed object. "

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now