none
Best modern approach to define PODS classes in C# and use in unmanaged C++ and Windows Store Apps. RRS feed

  • General discussion

  • Hello,

    I'm developing a distributed system consisting off a number of applications, some running on the same machine some running on different machines. The majority of the code is in C#. However, at least one of the applications is in native C++ and another is a 'Windows Store App'. I'm using the latest technology Windows 8.1, VS 2013.

    I'm going to be using common PODS (Plan Old Data Structures) classes between all applications. I would like to define these plain data classes in a central location in C# and have them automatically available for use in a my C++ application.

    One way I think is to make these classes COM visible as described here:

    http://social.msdn.microsoft.com/Forums/en-US/9a0a09cb-32d1-4478-8f84-be195932f5e6/c-com-object-used-in-c?forum=csharplanguage

    In addition, I would like to use these classes definition in my RPC, where the C++ application is the server and the my C# application is the client.

    Is there a better approach then using COM RPC? Any suggestions on good reference articles?

    EDIT:

    After thinking about it more I've come up with this list of 'wants' ranked in priority:

    1. Data structures and interfaces defined in a central location.
    2. Client/server functionality built in.
    3. Serialization/deserialization of data objects from the communication stream built in.
    4. Binary encoding.
    5. Named Pipe transport option for local computer IPC (faster more secure)
    6. Free
    7. Language of the data structures and interfaces be in C# (1st choice) or C/C++(2nd choice) 

    Thank you,

    Joe


    • Edited by jfradley Thursday, May 29, 2014 10:42 PM Added binary encoding
    • Changed type Fred BaoModerator Thursday, June 5, 2014 3:38 AM The discussion type is more suitable for this case
    Wednesday, May 28, 2014 6:07 PM

All replies

  • Hello,

    >>Is there a better approach then using COM RPC?

    It seems that you are trying to connect the sever written by C++ from the client written by C#, I think you can also use the Windows Sockets to write the C++ server, and use Socket Class to write the client.

    Socket is to send byte, so it needs to convert the object to byte in client and convert byte to object in server.

    I do not know whether it is better that COM/RPC since it needs to do a convert operation, you may have a try.

    If I misunderstand, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 29, 2014 7:39 AM
    Moderator
  • Hi Fred, 

    Thanks for the reply. Sockets could work but it doesn't get me everything I want. I updated my post with more information. With sockets I'll have to hand roll serialization/deserialization, I'd have similar classes defined in two places (one in C# and another in C++), I'd have to client/server functionality myself, and I won't have the speed advantage of using Named Pipes.

    Joe

    Thursday, May 29, 2014 10:36 PM
  • The best I can currently come up with is Apache Thrift 'http://thrift.apache.org/'. It only fails on defining in C# or C++.

    1. Data structures and interfaces defined in a central location.

    <Yes, defined inside *.thrift files>

    2. Client/server functionality built in.

    <Yes>

    3. Serialization/deserialization of data objects from the communication stream built in.

    <Yes>

    4. Binary encoding

    <Yes>

    5. Named Pipe transport option for local computer IPC (faster more secure)

    <Yes, pending next release v0.9.2>

    6. Free

    <Yes>

    7. Language of the data structures and interfaces be in C# (1st choice) or C/C++(2nd choice) 

    <No. Defined in a *.thrift file and not either a *.cs or *.h>

    It would be nice if I could use built in Windows feature that satisfied all of this.

    Thursday, May 29, 2014 10:47 PM