我试图在我的asp.net网站上使用几个库,我使用NuGet.
问题是我收到此错误:
Could not load file or assembly 'AWSSDK, Version=1.5.9.1, Culture=neutral, PublicKeyToken=cd2d24cd2bace800' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)
我试图使用的其中一个库需要使用AWSSDK,但显然它正在寻找一个我无法再获得的旧版本.
是否可以忽略此错误?
这是一个没有代码的全新网站,只是NuGet引入的内容,web.config为空.
我添加了Fusion日志,现在我得到:
=== Pre-bind state information ===
LOG: User = WIN-FSSH1EIG4NE\Max
LOG: DisplayName = AWSSDK, Version=1.5.9.1, Culture=neutral, PublicKeyToken=cd2d24cd2bace800
(Fully-specified)
LOG: Appbase = file:///C:/Users/Max/Documents/Visual Studio 2010/WebSites/images.RepZio/
LOG: Initial PrivatePath = C:\Users\Max\Documents\Visual Studio 2010\WebSites\images.RepZio\bin
Calling assembly : ImageResizer.Plugins.S3Reader, Version=3.3.2.447, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Max\Documents\Visual Studio 2010\WebSites\images\web.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: AWSSDK, Version=1.5.9.1, Culture=neutral, PublicKeyToken=cd2d24cd2bace800
LOG: Attempting download of new URL file:///C:/Users/Max/AppData/Local/Temp/Temporary ASP.NET Files/root/8dcd52e9/53da58e/AWSSDK.DLL.
LOG: Attempting download of new URL file:///C:/Users/Max/AppData/Local/Temp/Temporary ASP.NET Files/root/8dcd52e9/53da58e/AWSSDK/AWSSDK.DLL.
LOG: Attempting download of new URL file:///C:/Users/Max/Documents/Visual Studio 2010/WebSites/images/bin/AWSSDK.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Run Code Online (Sandbox Code Playgroud)
如果我添加如下面的评论中提到的bindingRedirect,我会得到相同的错误.
最新的(1.5.13.0)AWSSDK版本似乎已使用与之前版本不同的密钥签名.所以不幸的是bindingRedirect不起作用.
请按以下步骤操作:
打开包管理器控制台(工具>库包管理器>包管理器控制台)并键入:
PM> Uninstall-Package -Force AWSSDK
Run Code Online (Sandbox Code Playgroud)
其次是:
PM> Install-Package AWSSDK -Version 1.5.12.1
Run Code Online (Sandbox Code Playgroud)
然后仔细检查您的web.config文件.确保它仅包含以下AWSSDK的绑定重定向:
<dependentAssembly>
<assemblyIdentity name="AWSSDK" publicKeyToken="cd2d24cd2bace800" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.12.1" newVersion="1.5.12.1" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
现在,您的项目应该很好.