Native C Dll calling C ++ / CLI Mixed Dll - unhandled exception

I have a Native C Dll dynamically loaded by an outdated application. The purpose of this DLL is to allow redefinition of application behavior based on specific application events. I have a C # dll that contains functions that I call from Native C dll through a C ++ / CLI mixed-mode DLL to improve these application events. An application using this architecture runs flawlessly in Windows 2000.

The application also works on Windows XP, but unfortunately the application crashes (Unhandled Exception) when the Native C dll loads when the application starts. It looks like it will work when it tries to load a mixed-mode DLL. I removed all the dependencies in the mixed mode dll from the Native C dll, and the application loaded fine. But as soon as the dependency is added, it crashes. The code in Windows 2000 is the same as in Windows XP. I do not have access to the application code, but I have access to the Native C dll code, but it cannot force the debugger to stop as a failure occurs until initialization is complete. I suspect this is due to CLR initialization and OS bootloader differences, but I'm not sure. I am looking for suggestions on how to solve this problem. I am using VS2005 using the 2.0 Framework. I appreciate any helpwhich you could give.

Exception and stack trace may not be useful:

Unhandled exception at 0x775125f6 in MyApplication.exe: 0xC0000005: Read access violation location 0x775125f6.

775125f6()  
user32.dll!7e418734()   
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]    
user32.dll!7e418816()   
user32.dll!7e428ea0()   
user32.dll!7e42ce7c()   
ntdll.dll!7c90e473()    
user32.dll!7e42e389()   

...

+3
source share
2 answers

I had this exact problem. I have provided some additional information and workarounds for this question . But I am happy to summarize and give an answer here.

, , - , -, , DLL DLL. , , DLL , DLL, .

  • 1: DLL .
  • 2: exe , CLR. , , .
  • 3. , .

3, , . " ", "Linker- > Input tab". lib dll . , lib lib, .

Additional Dependencies:  mixedmode.lib; unmanaged.lib;. unmanaged2.lib

, , . lib, .lib , .

, !

+2

, . , :

7 8

+1

Source: https://habr.com/ru/post/1722079/


All Articles