locked
C++ - Serializing class instances with MSMQ RRS feed

  • Question

  • Hi there,

    I'm writing two pieces of software - one in native C++ (i.e. not C++/CLI) and one in C# which need to communicate via MSMQ.  The C# app needs to be in .NET because of some GUI controls which we need to use which only have .NET bindings, and the C++ app needs to be in native C++ because it’s functioning as a communications layer between the C# app and a third party app which is in native C++. 

    C# provides an excellent mechanism for serialising instances of classes over MSMQ (I'm using an XMLFormatter). I can't seem to find any documentation about how to serialise/deserialise instances of classes over MSMQ in C++.

    In theory I could continue to use the XMLFormatter on the C# side and just use an XML parser on the C++ side to read and build messages, but I was wondering if there is a standardized method for this?

    I'm currently using MSMQ with the WinAPI on the C++ side of things, but I'm not opposed to switching to COM if that will make my life easier. However I can't convert the MSMQ C++ code to C++/CLI for the reasons noted above.

    Is there a simple way of serialising instances of classes and sending them through an MSMQ in C++ (as well and receiving and deserialising), or do I need to do it myself using an XML Parser?

    Thanks,

    Rik

    Monday, February 4, 2013 10:47 AM

All replies

  • It's been a long time since I used C++ so I won't comment on that. But you could consider exposing your c# code with COM and have your C++ consume the component. That way you can re-use the same serialization component.

    http://pauliom.wordpress.com

    Tuesday, February 5, 2013 12:55 PM
  • Hi pkr2000, thanks very much for the response.

    Do you have a code sample or a link to an article?  I can't seem to find anything about message serialization in COM. 

    Tuesday, February 5, 2013 1:03 PM
  • You do the message serialization in c#, but make the c# com callable by simply adding the com attributes to the class/methods.

    http://pauliom.wordpress.com

    Tuesday, February 5, 2013 1:47 PM