> Hi,
> we found a problem with the way managed MFC dlls work:
[quoted text clipped - 12 lines]
> Thanks,
> Frank
Frank,
What exactly do you mean with "managed initialization is done"? And what
exactly are "Funny problems"?
You CWinApp is a native class so it's instance is not handled by the CLR,
but by MFC. As your MFC app. is a mixed application, that is the MFC libary
linked in is still unmanaged code, your classes are still native, all there
is done by the CLR is JITting your applications code from IL to native X86
code.
Willy.
PS. As this relates to VC++ I would suggest you post to the more appropriate
NG at microsoft.public.dotnet.languages.vc.
Frank Samuel - 20 Dec 2005 17:21 GMT
Hi Willy,
thanks for your answer.
This is mainly what we found out so far:
If a cpp which is compiled with /clr includes afxdisp.h, the MFC include
files tell the linker to also link with postdllmain.obj
If the postdllmain.obj is linked, some static variable inside MFC (something
like usemanagedinitialization) is set to 1.
When the dll is loaded the dllmain of MFC constructs all the unamanged
globals, and if the variable is 1 it skips InitInstance totally
The initinstance is later executed using "internaldllmain" call from .cctor
of managed global object which is inside the postdllmain.obj
The funny effects are mainly based on our construction code, which is
usually executed in InitInstance.
But I'm also not sure if MFC behaves correctly if we call AFX_MANAGE_STATE()
and InitInstance is not yet called.
Frank
>> Hi,
>> we found a problem with the way managed MFC dlls work:
[quoted text clipped - 25 lines]
> PS. As this relates to VC++ I would suggest you post to the more
> appropriate NG at microsoft.public.dotnet.languages.vc.