Re: MFC extension dll initialization
I found out that this problem causes the application compatibility settings.
If it is compatibility settings turn off everything works fine. But when is
turn on
Registry settings are:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\WINDOWS\\explorer.exe"="EnableNXShowUI"
Then it crashes in _CRT_INIT at line 293
if (__native_startup_state != __uninitialized)
{
_amsg_exit( _RT_CRT_INIT_CONFLICT);
}
Here is call stack:
msvcr80d.dll!_NMSG_WRITE(int rterrnum=31) Line 198
msvcr80d.dll!_amsg_exit(int rterrnum=31) Line 450 + 0x9 bytes
mfc80d.dll!_CRT_INIT(void * hDllHandle=0x781d0000, unsigned long dwReason=1,
void * lpreserved=0x0013fd30) Line 293 + 0x7 bytes
mfc80d.dll!__DllMainCRTStartup(void * hDllHandle=0x781d0000, unsigned long
dwReason=1, void * lpreserved=0x0013fd30) Line 492 + 0x11 bytes
mfc80d.dll!_DllMainCRTStartup(void * hDllHandle=0x781d0000, unsigned long
dwReason=1, void * lpreserved=0x0013fd30) Line 462 + 0x11 bytes
"Ajay Kalra" wrote:
"Palo Misik" <PaloMisik@discussions.microsoft.com> wrote in message
news:4D6FD854-B948-4E23-9843-70B37E9BC1A5@microsoft.com...
On
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/
_MFCNOTES_TN033.asp
in section Initializing the DLL I read that I have to do. But there isn't
explanation if I have to do that when I use that dll from other dll and
concurrently from application.
Because there is nothing special in what you are doing.
If I do that then I'll create more then one instances of CDynLinkLibrary
for
that dll. Is it correct?
No. A DLL will be loaded only once in your space.
On some computers it make a problem.
We have a lot installations where application run correctly, but we have
problematic installation, where program don't start.
We get a message
Runtime Error
R6031 - Attempt to initialize the CRT more then once.
I think that problem is in dll initialization.
If you think so, put a break point in DLLMain. Process_Attach and Detach are
going to be called but you shouldnt be initializing your stuff in it as
these are called each time a dll is loaded/unloaded in your process.
--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com