我有一个C#程序链接到(大)第三方库并使用它成功构建。包括我的程序和库之间的所有必要参考,程序正确启动。
在为上述库加载.NET托管DLL时,我得到一个System.IO.FileNotFoundException
,表示无法加载库或其中一个依赖项(“无法找到指定的模块。”)。
由于相关的DLL存在于Release
目录中,因此我查看了融合事件日志,发现只有不存在的<PROJECT>.resource.<DLL|EXE>
目录下的一堆不存在的Release\en
文件的绑定失败。这对我来说没有多大意义,因为项目的唯一资源(单个图标)是内化的。
日志看起来像这样,一些信息被编辑:
*** Assembly Binder Log Entry (7/11/2016 @ 10:08:49 AM) ***
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:\Users\USER\Desktop\PROJECT\bin\x86\Release\PROJECT.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = PROJECT.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = PROJECT.vshost.exe
Calling assembly : PROJECT, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\USER\Desktop\PROJECT\bin\x86\Release\PROJECT.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/en/PROJECT.resources.DLL.
LOG: Attempting download of new URL file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/en/PROJECT.resources/PROJECT.resources.DLL.
LOG: Attempting download of new URL file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/en/PROJECT.resources.EXE.
LOG: Attempting download of new URL file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/en/PROJECT.resources/PROJECT.resources.EXE.
LOG: All probing URLs attempted and failed.
更新:这是Process Monitor在加载DLL时显示的内容:
前三个加载是相关的DLL,以下是(表面上)它的依赖项,所有这些都来自标准的VS C ++可再发行组件。