Problem using CLR in MFC ActiveX controls
-
I recently discovered MFC support for winforms, and have been using it to host .Net Controls in my MFC activeX controls. This all worked beautifully, until recently when we started getting an assertion from msilexit.cpp during shutdown of the hosting application. The assertion is due to a user breakpoint, which originates from the __clrcall _exit_callback function. extern "C" void __clrcall _exit_callback(void) { ... if ( *__onexitend != NULL ) (**__onexitend)(); ... } Here are the facts that I have been able to collect. 1. There are no exceptions generated after you dismiss the assertion. 2. The application seems to have no problems in release. 3. There seems to be a correlation between the assertion and the number of "clr enabled" activeX libraries that have been loaded into memory. The magic number seems to be three. If you only load two "clr enabled" activeX's during the application lifetime, no assertion. My output window, when the assertion occurs, looks like this: 'VRExplorer.exe': Unloaded 'F:\VirtualRack\Trunk\Source\BuiltComponents\Debug\VRSystem\VRGUIControls.ocx' 'VRExplorer.exe': Unloaded 'F:\VirtualRack\Trunk\Source\BuiltComponents\Debug\VRSystem\VRGUIPanelWatch.ocx' 'VRExplorer.exe': Unloaded 'F:\VirtualRack\Trunk\Source\BuiltComponents\Debug\VRSystem\VRServiceLoggerPanel.ocx' 'VRExplorer.exe': Unloaded 'F:\VirtualRack\Trunk\Source\BuiltComponents\Debug\VRSystem\VRBitmaps.ocx' The thread 0x11d4 has exited with code 0 (0x0). The thread 0x16ec has exited with code 0 (0x0). The thread 0x230 has exited with code 0 (0x0). The thread 0x11bc has exited with code 0 (0x0). VRExplorer.exe has triggered a breakpoint Thanks for your help, Aaron