3

I am a newbie to C#. I am currently working on learning C# code. My final goal is to convert a C# project into a dll so that I can use it in my C++ exe. I am using VS2005.

I was wondering if it's possible and if so I would appreciate for some guidance and suggestions in this regards,

Please do reply back,

user2829
  • 451
  • 1
  • 7
  • 21

2 Answers2

3

Why not to make a com object out of your managed lib and call it from the unmanaged c++ code? It's relatively easy to do if you know how to manage com in c++.. http://msdn.microsoft.com/en-us/library/aa645736(v=vs.71).aspx

dexter
  • 7,063
  • 9
  • 54
  • 71
  • - Thank you so much for your quick reply. My C++ exe takes DLL's ( dynamic linking ) on the run time. I don't want to change the C++ exe code but if i can compile C# code ( which is a wrapper ) into a dll with few function mappings to match that my C++ exe code is looking for would be awesome...:) – user2829 Apr 01 '11 at 18:26
1

Write a C++/CLI wrapper around the C# DLL that exposes a native C++ interface to the C# code.

You'll probably need to enable the /clr flag in your application, but there are ways to expose a completely native interface via a DLL too.

There is a good explanation and sample implementation of the various techniques at this link.

Soo Wei Tan
  • 3,262
  • 2
  • 34
  • 36