How to call a C# Dll from C++ ??
-
Hi, is there a possibility to call functions from a DLL written with C# from managed/unmanaged c++ code? I know it is very simple to create a C#DLL and then use the function in a C# Project with adding a reference. This is really great and simple. But... I have a very big project written with VC++6.0. I solved all problems after converting it to VC++7.0. But now I want to use the big, great new features like ADO.NET to connect to a SQL-Server. So I thought to write some C#DLLs with all the functions I need and then call these functions from C++. How can I do this? I tried several things. 1.) Is it possible to add a reference to a C#Dll from C++ ? I can't see a posibility... 2.) The old common way with LoadLibary is not possible, because I can't declare my function in the Dll as a dllexport function, and because of this GetProcAdress returns zero. :(( So how can I declare my function for external use ? Any ideas?? :confused: :confused: Thanks for help.
-
Hi, is there a possibility to call functions from a DLL written with C# from managed/unmanaged c++ code? I know it is very simple to create a C#DLL and then use the function in a C# Project with adding a reference. This is really great and simple. But... I have a very big project written with VC++6.0. I solved all problems after converting it to VC++7.0. But now I want to use the big, great new features like ADO.NET to connect to a SQL-Server. So I thought to write some C#DLLs with all the functions I need and then call these functions from C++. How can I do this? I tried several things. 1.) Is it possible to add a reference to a C#Dll from C++ ? I can't see a posibility... 2.) The old common way with LoadLibary is not possible, because I can't declare my function in the Dll as a dllexport function, and because of this GetProcAdress returns zero. :(( So how can I declare my function for external use ? Any ideas?? :confused: :confused: Thanks for help.
The easiest thing to do would be to wrap your C# dll with COM (C# classes can be exposed as COM objects), then you can use COM to call into your C# dll... In MC++ you might be able to #using your dll like you would the system dlls. HTH, James Sonork ID: 100.11138 - Hasaki "Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. :-D" - Michael P Butler Jan. 18, 2002
-
The easiest thing to do would be to wrap your C# dll with COM (C# classes can be exposed as COM objects), then you can use COM to call into your C# dll... In MC++ you might be able to #using your dll like you would the system dlls. HTH, James Sonork ID: 100.11138 - Hasaki "Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. :-D" - Michael P Butler Jan. 18, 2002
-
The easiest way is to write an unmanaged C++ library that exports the functions you want. It then contains managed C++ that calls your C# classes directly. This gives you the best of both worlds, but requires two files. One for C++ and one cor C#.
ohhh! I forgot about that :-O James Sonork ID: 100.11138 - Hasaki "Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. :-D" - Michael P Butler Jan. 18, 2002