nakori
nakori

Reputation: 57

Bridge between old C++ app and a new C# app

We have an old C++ application that have a services layer. A new app will be developed in C#. Before it's completed things should be shared between them. A new item in C# might need to be implemented in the existing system and vice versa.

Service messages in the existing layer consists of text strings with commands. I need to build a broker between existing services and a new service in C#.

I guess I will need at least two input (C++/C#) and two output (C++/C#) functions in the service unless it's better to make input and output more generic.

Anyone have an example of such a service that acts as a bridge between the systems (Exchanging text strings)? For example is WCF recommended for this?

thanks

regards, Nakori

Upvotes: 1

Views: 284

Answers (1)

GMasucci
GMasucci

Reputation: 2882

For your needs to rapidly support the C++ code in C# you might consider a wrapper as illustrated at http://www.codeproject.com/Articles/19354/Quick-C-CLI-Learn-C-CLI-in-less-than-10-minutes#A8

There are further examples here and here.

It would give a temporary solution whilst the C# native code is being crafted.

You can also use Platform Invoke (with a tutorial and samples here):

  • what you need to do is create a function header for each function in your unmanaged DLL;
  • specify to .NET in which DLL the function resides;
  • now you can utilise any of those functions as you would any normal .NET function.

You will need to pay particular attention to matching the datatypes correctly, and it helps to have the function definitions for the C++ based code to hand to help define the C# ones.

Let me know if you need more information:)

Upvotes: 2

Related Questions