C++ MFC DLL referencing to C#

  • Thread starter Thread starter Varangian
  • Start date Start date
V

Varangian

I made an MFC DLL in C++ . I want to reference it in C#.

However I don't know where to put the function to be called from C# ?
After referencing the DLL no methods are visible in the C# object
browser.

Anyone knows please?
 
Varangian said:
I made an MFC DLL in C++ . I want to reference it in C#.

However I don't know where to put the function to be called from C# ?
After referencing the DLL no methods are visible in the C# object
browser.

Anyone knows please?

Hi Varangian,

would be good if it would be that simple ;-).
I suppose you've created a native Dll and you have 3 options to access
the functions / objects in the MFC Dll.

a) COM Interop - wrap your functions in COM objects.
(Most) COM/ActiveX objects can be accessed directly by C#

b) PInvoke: Export the functions in the dll with
__declspec(dllexport)
and import them with DllImport attribute

c) Create a mixed Dll: due to the "loader lock" problem I would suggest
you to do this only with VC 2005 not with VC 2003.
You can export C++/CLI wrapper objects, which are directly accessible
from C#.


Hope that helps.
Andre
 
Thanks andre kaufman for the interest in replying :)

I used the DLL import and it worked fine.. but thats not what I wanted.
Now it works I leave it as it is now :) thanks again
 
Varangian said:
Thanks andre kaufman for the interest in replying :)
:-)

I used the DLL import and it worked fine.. but thats not what I wanted.

Yes - would be nice if that wouldn't need that much handwork ;-)
Now it works I leave it as it is now :) thanks again

Thanks, too.
 
Back
Top