C ++ \CLI应用程序在加载时崩溃 [英] C++\CLI applicatin crash on load

查看:293
本文介绍了C ++ \CLI应用程序在加载时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++应用程序加载大量的C ++ DLL和几个选定的C ++ \CLI。在启动时,在其中一台机器(Windows Server 2003 SP2)上收到错误消息

I have a C++ app that loads lot of C++ DLL and few selected C++\CLI ones. On one of the machines (Windows Server 2003 SP2) on start-up I was getting error message


应用程序无法正确初始化(0xC0000005 )。

The application failed to initialize properly (0xC0000005). Click on OK to terminate the application.

当使用WinDbg打开应用程序而不是获得正确的DbgBbreak断点时,我得到这个:

When app was opened with WinDbg instead of getting proper DbgBbreak breakpoint I was getting this:

Microsoft (R) Windows Debugger Version 6.12.0002.633 X86
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: d:\appdir\MyTrueApp.exe
Symbol search path is: .sympath SRV*c:\localsymbols*http://msdl.microsoft.com/download/symbols
Executable search path is: 
ModLoad: 00400000 0044b000   MyTrueApp.exe
ModLoad: 7c800000 7c8c3000   ntdll.dll
ModLoad: 77e40000 77f42000   C:\WINDOWS\system32\kernel32.dll
ModLoad: 60200000 60264000   d:\AppDir\CustomCppDLL_ONE.dll
ModLoad: 76aa0000 76acd000   C:\WINDOWS\system32\WINMM.dll
ModLoad: 77380000 77411000   C:\WINDOWS\system32\USER32.dll
ModLoad: 77c00000 77c49000   C:\WINDOWS\system32\GDI32.dll
ModLoad: 7d1e0000 7d27c000   C:\WINDOWS\system32\ADVAPI32.dll
ModLoad: 77c50000 77cf0000   C:\WINDOWS\system32\RPCRT4.dll
ModLoad: 76f50000 76f63000   C:\WINDOWS\system32\Secur32.dll
ModLoad: 10000000 10023000   d:\AppDir\CustomCppDLL_TWO.dll
ModLoad: 7c420000 7c4a7000   C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.5592_x-ww_179798C8\MSVCP80.dll
ModLoad: 78130000 781cb000   C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.5592_x-ww_179798C8\MSVCR80.dll
ModLoad: 77ba0000 77bfa000   C:\WINDOWS\system32\msvcrt.dll
ModLoad: 60300000 60332000   d:\AppDir\CustomCppDLL_3RD.DLL
ModLoad: 781d0000 782df000   C:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFC_1fc8b3b9a1e18e3b_8.0.50727.5592_x-ww_E87E0BCD\MFC80.DLL
ModLoad: 7d180000 7d1d2000   C:\WINDOWS\system32\SHLWAPI.dll
ModLoad: 77670000 777a9000   C:\WINDOWS\system32\ole32.dll
ModLoad: 77d00000 77d8b000   C:\WINDOWS\system32\OLEAUT32.dll
ModLoad: 00360000 00375000   d:\AppDir\CustomCppDLL_4th.DLL
ModLoad: 60800000 6081a000   d:\AppDir\CustomCppDLL_5th.DLL
ModLoad: 60600000 6074b000   d:\AppDir\CustomCppDLL_6th.DLL
ModLoad: 003b0000 003c5000   d:\AppDir\CustomCppDLL_7th.DLL
ModLoad: 77b90000 77b98000   C:\WINDOWS\system32\VERSION.dll
ModLoad: 00450000 004d6000   d:\AppDir\CustomCppDLL_7th.DLL
ModLoad: 7c8d0000 7d0cf000   C:\WINDOWS\system32\SHELL32.dll
ModLoad: 61880000 618bb000   C:\WINDOWS\system32\OLEACC.dll
ModLoad: 73070000 73097000   C:\WINDOWS\system32\WINSPOOL.DRV
ModLoad: 762b0000 762f9000   C:\WINDOWS\system32\comdlg32.dll
ModLoad: 77530000 775c7000   C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_5.82.3790.4770_x-ww_A689AB02\COMCTL32.dll
ModLoad: 004e0000 00506000   d:\AppDir\CustomCppDLL_9th.DLL
ModLoad: 00510000 00547000   d:\AppDir\CustomCppDLL_10th.DLL
ModLoad: 71c00000 71c17000   C:\WINDOWS\system32\WS2_32.dll
ModLoad: 71bf0000 71bf8000   C:\WINDOWS\system32\WS2HELP.dll
ModLoad: 76cf0000 76d0a000   C:\WINDOWS\system32\iphlpapi.dll
ModLoad: 76b70000 76b7b000   C:\WINDOWS\system32\PSAPI.DLL
ModLoad: 6d580000 6d628000   C:\WINDOWS\system32\dbghelp.dll
ModLoad: 00560000 0056a000   d:\AppDir\CustomCpp_CLI.DLL
ModLoad: 79000000 7904a000   C:\WINDOWS\system32\mscoree.dll
ModLoad: 71bc0000 71bc8000   C:\WINDOWS\system32\rdpsnd.dll
ModLoad: 771f0000 77201000   C:\WINDOWS\system32\WINSTA.dll
ModLoad: 71c40000 71c97000   C:\WINDOWS\system32\NETAPI32.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdll.dll - 
(1510.1304): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.

kc 命令

ntdll!LdrOpenImageFileOptionsKey
ntdll!LdrQueryImageFileExecutionOptionsEx
ntdll!LdrQueryImageFileExecutionOptions
ntdll!RtlIpv4StringToAddressExW
ntdll!RtlLogStackBackTrace
ntdll!LdrGetProcedureAddress
ntdll!EtwTraceMessage
ntdll!RtlIsThreadWithinLoaderCallout
ntdll!RtlGetActiveActivationContext
ntdll!RtlGetActiveActivationContext
ntdll!RtlGetActiveActivationContext
ntdll!RtlGetActiveActivationContext
ntdll!RtlGetActiveActivationContext
ntdll!RtlGetActiveActivationContext
ntdll!CsrClientConnectToServer
ntdll!KiUserApcDispatcher

Googling for ntdll!LdrOpenImageFileOptionsKey 显示它是系统加载器。没有更多的帮助,从这里除了看起来一个可怜的家伙有类似的问题,但没有解决方案。有一次载入错误的混合程序集,但它是为Visual Studio 2003和我是在2005年和.NET Framework 2.0。

Googling for ntdll!LdrOpenImageFileOptionsKey reveals that it is a part of a system loader. No more help from here except that it seems one poor guy had a similar issue but without solution. There was once a bug in loading of mixed assemblies but it was for Visual Studio 2003 and I was on 2005 and .NET Framework 2.0.

在绝望中,我尝试了。Net Framework修复但是当然没有运气。我回到了 Google ,并获得此帖子有一个小线索。它表示

In sheer despair I tried .Net Framework repair but of course with no luck. I went back to Google and got this post that had a small clue. It states


由于您收到错误消息
在处理期间抛出了未处理的不可继续的
异常b $ b load,似乎问题是由
引起的一个与DLL
文件相关的难题引起的。在这个主题上有几个讨论
,也许其中一些可以
help:

Since you received the error message "An unhandled non-continuable exception was thrown during process load", it seems the problem is caused by a difficult issue related to DLL files. There are several discussions on this topic, maybe some of them can help:

  http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=325627&SiteID=1
  http://groups.google.com/group/microsoft.public.vc.mfc/browse_thread/thread/560a31bb72b2bca8/44fb800374c2f3b0%2344fb800374c2f3b0
  http://groups.google.com/group/microsoft.public.dotnet.languages.vc/browse_thread/thread/1243abff27e677ae/901c0a23deec7e47%23901c0a23deec7e47


前两个链接没有用,但最后一个提到类似问题 / DELAYLOAD linker option help。通过将 CustomCpp_CLI.DLL 设置为可延迟加载,我得到了我的解决方案。

First two link are no use but the last one mentions that with similar problem /DELAYLOAD linker option helped. By setting CustomCpp_CLI.DLL as delay loadable I got my solution. My application rock'n'rolls now!

我仍然不知道为什么这会有帮助的原因。另一方面,我的C ++ DLL在DllMain和 Larry Osterman Raymond Chen a>写这是可怕。也许我的DLLs用装载器弄乱了?我不知道。

I still don't know exactly a reason why this helps. On the other side my C++ DLL do some strange stuff in DllMain and as Larry Osterman and Raymond Chen write this is scary. Maybe my DLLs mess somehow with loader? I don't know.

我写为 AAR(After Action Report) so it pops在Google搜索结果中出现,并且将来一天会有不良的灵魂,因此Internet 是一个更好的地方。

I wrote this as a AAR (After Action Report) so it pops out in Google results and will poor soul one day in the future so Internet is a better place.

BTW如果有人知道为什么 / DELAYLOAD

BTW If someone knows why /DELAYLOAD helped please enlighten me.

推荐答案

我今天在Windows 2003 SP2服务器上有一个类似的问题..我发现的解决方案是延迟加载有问题的dll。

I had a similar issue today on a Windows 2003 SP2 server .. and the solution I found was to delay load the problematic dll.

https:// connect .microsoft.com / VisualStudio / feedback / details / 586715 / unmanaged-exe-linked-to-a-mixed-mode-dll-crashes-at-startup-on-some-xp-machines

我的主要应用程序在Delphi 2010中,我使用delphi中的延迟关键字,如

My main app was in Delphi 2010 and I used the delayed keyword in delphi as given in

http://www.drbob42.com/examines/examinC1.htm

它的工作原理就像一个魅力现在..

It works like a charm now ..

这篇关于C ++ \CLI应用程序在加载时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆