Calling C# from C++, Reverse P/Invoke, Mixed Mode DLLs and C++/CLI
c#, c++, c++-cli, clr
Solution
Here are the answers to the best of my knowledge:
- Yes
- Yes, it is a mixed mode DLL (In fact, you can make one file of your native C++ project managed and create this C++/CLI class in that file and call the code directly from that file. You don't even need a separate DLL to accomplish this.
- C++/CLI and Managed C++ both represent same thing. The only difference is that in the older version till Visual Studio 2003, it was termed as Managed C++. Later on, the syntax was changed quite a lot and it was renamed as C++/CLI. Have a look at this link for details.
- Yes
- CLR will be used whenever a call to the managed DLL is made.
Problem
As I understand it I can use reverse P/Invoke to call C# from C++. Reverse P/Invoke is simply a case of: - Create you managed (c#) class. - Create a c++/cli (formerly managed c++) class library project. Use this to call the managed c# class (presumably via a reference). - Call the c++/cli code from native c++. Questions: - Is this correct? - Is the DLL created at step 2 known as a mixed mode DLL? - Has C++/CLI completely superseded Managed C++ as far as MS are concerned? - Is COM completely avoided using this approach? - At what point would the CLR be created and run, and by whom? Thanks in advance