More informations:
The DLL is dynamically loaded with LoadLibrary.
The exception is generated when calling an exported function. I have reduced
the code of this function to just return (do nothing), and it never return
but fails. It seems that it is a .NET Framework loading issue.
Here is the output of the VS2005 debugger :
'testoledb.exe': Loaded 'C:\Program Files\RTE\RTE FAX\FAX
Server\OLEDB\rtefcddbxp.dll', Symbols loaded.
'testoledb.exe': Loaded 'C:\WINDOWS\system32\mscoree.dll', No symbols
loaded.
'testoledb.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols
loaded.
'testoledb.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700\msvcr80.dll',
Symbols loaded.
'testoledb.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFC_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_3bf8fa05\mfc80.dll',
Symbols loaded.
'testoledb.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700\msvcm80.dll',
Symbols loaded.
'testoledb.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFCLOC_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_91481303\mfc80FRA.dll',
Binary was not built with debug information.
'testoledb.exe': Loaded
'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll', No symbols
loaded.
'testoledb.exe': Loaded
'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Culture.dll', No symbols
loaded.
'testoledb.exe': Unloaded
'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Culture.dll'
'testoledb.exe': Loaded
'C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\dfe5673f59b9b9439038f27549b30383\mscorlib.ni.dll',
No symbols loaded.
'testoledb.exe': Loaded
'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll', No symbols
loaded.
'testoledb.exe': Loaded 'C:\WINDOWS\system32\rsaenh.dll', No symbols loaded.
First-chance exception at 0x7c97cc82 in testoledb.exe: 0xC0000005: Access
violation reading location 0x1e4b3411.
First-chance exception at 0x78138be3 (msvcr80.dll) in testoledb.exe:
0xC0000005: Access violation writing location 0x1e4b3412.
First-chance exception at 0x7c97df51 in testoledb.exe: 0xC0000005: Access
violation reading location 0x1e4b340a.
First-chance exception at 0x7c812a5b in testoledb.exe: Microsoft C++
exception: EEMessageException at memory location 0x0012d21c..
First-chance exception at 0x7c812a5b in testoledb.exe: 0xE0434F4D:
0xe0434f4d.
First-chance exception at 0x7c812a5b in testoledb.exe: 0xE0434F4D:
0xe0434f4d.
First-chance exception at 0x7c812a5b in testoledb.exe: 0xE0434F4D:
0xe0434f4d.
First-chance exception at 0x7c812a5b in testoledb.exe: Microsoft C++
exception: [rethrow] at memory location 0x00000000..
> Hello,
>
[quoted text clipped - 77 lines]
>
> Thanks for your Help.
Olivier Matrot - 09 May 2007 15:39 GMT
Another information :
The code fails in msstartup.cpp function void Initialize().
> More informations:
> The DLL is dynamically loaded with LoadLibrary.
[quoted text clipped - 157 lines]
>>
>> Thanks for your Help.
Olivier Matrot - 14 May 2007 13:41 GMT
In release mode, but linked with de debug version of the MFC redistribuable,
everything is fine.
May be there is a bug in the release version of the DLL.
> Another information :
> The code fails in msstartup.cpp function void Initialize().
[quoted text clipped - 160 lines]
>>>
>>> Thanks for your Help.
Olivier Matrot - 22 May 2007 08:25 GMT
Found the solution this morning after spending one day investigating this
weird behavior :
I missed to tell yet that my project was initially created in Visual Studio
.NET (and converted in VS2005). So, I started a similar project from scratch
in VS2005 and was not able to reproduce the problem !
I compared each project settings to finally find out that a "/NOENTRY"
linker advanced option is present in the failing project !?! I removed this
option and rebuilt the project. It failed with a linking error "_DllMain@12
already defined in msvcrt.lib". With the /VERBOSE option, I have compared
the libraries used in both project.
It turns out that the MFC libraries must be linked before the CRT libraries
!!! This explains that unmanaged code calling managed code fails. So simply
ignore and include "mfcs80.lib" in the linker input options.
> In release mode, but linked with de debug version of the MFC
> redistribuable, everything is fine.
[quoted text clipped - 164 lines]
>>>>
>>>> Thanks for your Help.