为什么我的 .NET 应用程序尝试加载不相关的 DLL 文件? (调试输出中第一次出现 System.BadImageFormatException)
在调试时,我注意到这里的这个 C# 应用程序出现以下情况:
它似乎尝试加载恰好与可执行文件驻留在同一目录中的所有 DLL 文件。 (即使是那些与此项目/解决方案中的任何内容完全无关的应用程序。)
该应用程序正在加载并正常工作,但是我发现调试输出很奇怪:(路径被剪断)
...
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
'my_test.exe': Loaded '....\release\mfc42u.dll', Symbols loaded (source information stripped).
'my_test.exe': Unloaded '....\release\mfc42u.dll'
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
'my_test.exe': Loaded '....\release\mpiwin32.dll', Binary was not built with debug information.
'my_test.exe': Unloaded '....\release\mpiwin32.dll'
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
...
上面的两个 DLL 与 C# 项目或它引用的任何内容。为什么可执行文件(或 VS 调试器?)尝试加载这些 DLL?
While debugging, I notice the following with this C# app I have here:
It appears to try to load all DLL files that happen to reside in the same directory as the executable. (Even ones that are completely unrelated to anything in this project/solution.)
The app is loading and working fine, however I find the debug output weird: (paths snipped)
...
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
'my_test.exe': Loaded '....\release\mfc42u.dll', Symbols loaded (source information stripped).
'my_test.exe': Unloaded '....\release\mfc42u.dll'
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
'my_test.exe': Loaded '....\release\mpiwin32.dll', Binary was not built with debug information.
'my_test.exe': Unloaded '....\release\mpiwin32.dll'
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
...
The two DLLs above have absolutely nothing to do with the C# project or anything it references. Why is the executable (or the VS debugger?) trying to load these DLLs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来这个应用程序毕竟正在主动加载这些 DLL!
我在一个我不熟悉的组件中找到了这段代码:
0xA3 关于捕获第一次机会异常的评论让我走上了正轨!
Seems this app is actively loading these DLLs after all!
This code I found in a component I was not familiar with:
0xA3's comment about catching the 1st chance exception got me on the right track!