【发布时间】:2012-03-16 09:43:30
【问题描述】:
我正在调试程序集加载问题,因此我正在查看融合日志。有时他们让我感到困惑,因为他们从指示失败开始,然后最后他们说程序集从我期望加载的位置加载。
“操作失败”后跟“从...加载 IL 程序集”的真正含义是什么?是加载程序集失败,还是成功了?
*** Assembly Binder Log Entry (2012-03-16 @ 10:25:14) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program\MyCorp\MyApplication1.2.0.0\MyApplication.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = VIRTUALXP-63912\XPMUser
LOG: DisplayName = MyCorp.MyApplication.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Program/MyCorp/MyApplication1.2.0.0/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MyApplication.exe
Calling assembly : MyApplication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Start binding of native image MyCorp.MyApplication.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
WRN: No matching native image found.
LOG: IL assembly loaded from C:\Program\MyCorp\MyApplication1.2.0.0\MyCorp.MyApplication.Core.dll.
即使程序退出并声明can't load file or assembly SomeAssembly or one of its dependencies,我也会看到此类程序集日志。根据与上述类似的日志条目加载有问题的程序集。
这是否表明未找到程序集的本机依赖项?我是否需要更改日志设置以查看哪个本机依赖项失败,或者我可以做些什么?
【问题讨论】:
-
这是整个日志吗?据我所知,没有失败(因为找到了
MyCorp.MyApplication.Core的本机映像,所以加载了找到的托管版本。 -
这是一个特定 dll 的日志。这个 dll 是一个托管 dll,据我所知,它加载成功。这就是为什么我想知道什么“失败”了。
-
查找另一个显示“其依赖项之一”绑定失败的日志条目。 SysInternals 的 ProcMon 可以显示它正在搜索非托管 DLL(如果这是原因)。忽略“找不到匹配的原生图片”,这很正常。
-
我根本看不到任何带有可疑绑定失败的日志条目。应用程序以 someassembly.dll“或其依赖项之一”的 fileloadexception 退出。 ProcMon 根本没有尝试加载 someassembly.dll 的迹象。