C ++ / CLI from the MFC DLL Extension Library

I have an MFC application that uses several MFC extension DLLs. I want this application (and several other similar applications) to be available to access some parts of the .net infrastructure. I wrote a C # library to do the .net work that I want, and was hoping I could write an MFC dll to hide all the C ++ / CLI code from my applications. Applications will remain pure MFC applications, and the only C ++ / CLI code will be in my new MFX DLL extension. However, when I did this, the applications crashed while accessing the new MFC C ++ / CLI DLL. If I put C ++ / CLI code in applications, it works fine, and I can completely debug my way to C #.

Does anyone understand why the dll idea is not working?

thank

+3
source share
3 answers

You cannot reference managed assemblies from pure code. You must either turn the / clr switch on to the consumer (both throughout the project and in specific files) or make one of them.

One interaction option that allows your consumer to say that pure native is a call to a managed assembly through COM Callable Wrapper .

+1
source

I think I ran into a similar problem. My setup was similar: a pure MFC application with a pure MFC DLL, which, in turn, interacted with the C ++ / CLI DLL. Everything will work fine, but on exit. The problem was exacerbated when testing a clean MFC DLL with CppUnit.

, - ++ (, ) . ++ , CLR . CLR , - /unit -test.

, , .

+1

The MFC dll project references the C # library and has one file compiled with / clr that processes the interface in my C # library. I actually saw this work sometimes at runtime, but could never debug in MFC dll or in C # code. However, in most cases, it does not seem absolutely stable and emergency.

0
source

Source: https://habr.com/ru/post/1698520/


All Articles