I'm having problems with my .net controls not getting cleaned up properly when wrapped for activeX use. Default behavior leaves the SDK's test container app (TstCon32.exe) running as a GUIless process when I try and close it. The workaround I initially found via google was to override WndProc and call Environment.Exit(0)
manually. This did get TstCon32.exe to shut down completely; however it's breaking the application where i need to have the control hosted. The App is MDI and WM_DESTROY is being sent when the page containing the control is closed, at which point the Environment.Exit(0)
call is blowing away the entire app. I've tried Application.Exit()
as an alternative, but that leaves TstCon32 still running invisibly.
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
// WM_DESTROY
if (m.Msg == 2)
Environment.Exit(0);
}