Groups | Blog | Home
all groups > dotnet interop > august 2006 >

dotnet interop : Native code unloads before Managed code


jornfa
8/18/2006 1:11:01 AM
I have a project where I use the MFC support for interop: <afxwinforms.h>,
CWinFormsControl<Ctrl> etc. This works fine exept for some problems when the
application closes down. Now and then I get an ASSERT in wincore.cpp l .2870
(WalkPreTranslateTree). Further I can see in the output window that the
native code unloads before the Managed code. Normally this is the other way
round as the EXE is a native C++ program, while the GUI is made up of
contained .NET controls.

Order of output in the debug window:
The program '[3328] Test.exe: Native' has exited with code 0 (0x0).
The program '[3328] Test.exe: Managed' has exited with code 0 (0x0).

Why do I still get messages to the WalkPreTranslateTree function after the
corresponding window is destroyed. And why does the managed code unload after
the native? And could these issues be related?

Any ideas? All help appreciated.

jornfa
8/31/2006 6:04:03 AM
Further problems seems to be bound to the cleanup in MFC with CWinformsControl:

1) There is a memory leak problem in viewform.cpp. It allocates an
_AFX_OCC_DIALOG_INFO structure on line 285, but this is never deallocated.
This is when you use the MFC class CFormView as the container. It is possible
to delete this internal MFC structure in your own code, but it flags a
problem.

2) 2 first chance exceptions is fired, which are "0xC0000005: Access
violation".

All this can be reproduced by a simple wizard generated MFC MDI program with
a CFormView based view class and a contained .NET user control through
CWinFormsControl.

Any ideas?

[quoted text, click to view]
AddThis Social Bookmark Button