views:

84

answers:

5

Imagine a project with a C# component and a C++ component. The C++ component is the old-school non .Net stuff (VC++ 6.0). What is an easy way to transfer objects between the two components? I'm tempted to use System.Xml.XmlSerializer, but I'm not sure how to start getting at the .Net libraries with this old VC++ app.

Maybe there's an even easier way that I haven't considered. Any suggestions?

+4  A: 

How do you feel about using COM? .NET applications can both consume COM objects and can expose themselves as COM objects.

John Saunders
+2  A: 

Make the C++ a COM Object ?

Hassan Syed
+4  A: 

Have a look at C++/CLI. You can write a wrapper with it that translates between both worlds.

Thorsten79
Far better then using COM, IMHO.
gimpf
A: 

If your C++ component is an unmanaged DLL exporting C-style functions "Platform Invoke" is another option. This technic allows access from .NET (C#) managed code to the unmanaged C++ code but not in the other direction.

Slauma
A: 

Depending how large your project is, I would recompile the VC6 stuff as C++/CLI with VS 2008. Then you can access the .net stuff directly.

Zanson