場景:動態庫UFileDev(運行時版本v4.0.30319)內置方法調用了動態庫ICSharpCode.SharpZipLib(運行時版本v2.0.50727)。調用動態庫UFileDev過程中一直報錯如下: Pre-bind state information LOG: DisplayName ...
場景:動態庫UFileDev(運行時版本v4.0.30319)內置方法調用了動態庫ICSharpCode.SharpZipLib(運行時版本v2.0.50727)。調用動態庫UFileDev過程中一直報錯如下:
=== Pre-bind state information ===
LOG: DisplayName = ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
(Fully-specified)
LOG: Appbase = file:///G:/program_test/WebApiTest/
LOG: Initial PrivatePath = G:\program_test\WebApiTest\bin
Calling assembly : UFileDev, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a7bcd44e2dce6fe6.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: G:\program_test\WebApiTest\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/webapitest/3f0358dc/ff934c92/ICSharpCode.SharpZipLib.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/webapitest/3f0358dc/ff934c92/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.DLL.
LOG: Attempting download of new URL file:///G:/program_test/WebApiTest/bin/ICSharpCode.SharpZipLib.DLL.
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
解決方案:
1. 修改app.config:
添加<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
2. 查看動態庫UFileDev屬性“強名稱”是否為true,應為FALSE。
關於強名稱的程式集介紹參考https://www.cnblogs.com/luminji/archive/2010/10/21/1857339.html