我遇到了我創建的C++/CLI混合模式DLL的問題。它在卸載時拋出異常,因爲使用它的.NET應用程序退出。 DLL_PROCESS_DETACH
被執行後,DLL確實運行清理使用自動註冊atexit()/__onexit()
功能,並拋出以下異常:混合模式C++/CLI DLL在退出時拋出異常
Unhandled exception at 0x752bb9bc (KernelBase.dll) in psstestm.exe:
0xC0020001: The string binding is invalid.
我追蹤的問題是由一個靜態加速異常對象get_static_exception_object()
註冊的atexit()
通話。
function_to_call 0x0f560410 [email protected][email protected][email protected][email protected][email protected]@@@[email protected]@@[email protected]@[email protected]@[email protected]@YAXXZ void (void)*
我使用boost_1_47靜態鏈接的大部分除了boost :: thread動態鏈接,以避免loaderlock。我也試着動態鏈接所有沒有幫助的提升。此外,所有的提升包括#pragma unmanaged
塊。
我希望有人有類似的問題或知道解決方案?
謝謝,馬克
這裏是調用堆棧發生之前的異常:
psscorem.dll!_CRT_INIT(void * hDllHandle=0x0f4b0000, unsigned long dwReason=0, void * lpreserved=0x00000001) Line 413 C
psscorem.dll!__DllMainCRTStartup(void * hDllHandle=0x0f4b0000, unsigned long dwReason=0, void * lpreserved=0x00000001) Line 526 + 0x11 bytes C
psscorem.dll!_DllMainCRTStartup(void * hDllHandle=0x0f4b0000, unsigned long dwReason=0, void * lpreserved=0x00000001) Line 476 + 0x11 bytes C
[email protected]() + 0xde bytes
[email protected]() + 0xad bytes
[email protected]() + 0x14 bytes
[email protected]() + 0x141 bytes
[email protected]() + 0x74 bytes
kernel32.dll!749479f5()
mscoreei.dll!RuntimeDesc::ShutdownAllActiveRuntimes() + 0xc8 bytes
mscoreei.dll!CLRRuntimeHostInternalImpl::ShutdownAllRuntimesThenExit() + 0x15 bytes
clr.dll!EEPolicy::ExitProcessViaShim() + 0x66 bytes
clr.dll!SafeExitProcess() + 0x99 bytes
clr.dll!DisableRuntime() - 0x1146bb bytes
clr.dll!EEPolicy::HandleExitProcess() + 0x57 bytes
[email protected]() + 0x11c bytes
[email protected]() + 0x1c bytes
[email protected]() + 0x38 bytes
[email protected]() + 0x227 bytes
[email protected]() + 0x8 bytes
[email protected]@12() + 0x12 bytes
[email protected]() + 0x27 bytes
[email protected]() + 0x1b bytes
謝謝!我一直在追蹤這個問題。我不知道C++是否足夠了解如何導致對atexit的調用。 – pedz