是否可以忽略程序集清单不匹配

本文关键字:程序集清单 不匹配 是否 | 更新日期: 2023-09-27 17:59:40

我正在尝试使用我的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)

我尝试使用的一个库需要使用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.

如果我添加bindingRedirect,我会得到同样的错误,如下面的评论中所述。

是否可以忽略程序集清单不匹配

最新的(1.5.13.0)AWSSDK版本似乎使用了与以前版本不同的密钥进行签名。不幸的是bindingRedirect无法工作。

按以下步骤进行:

打开包管理器控制台("工具">"库包管理器">"包管理器console"),然后键入:

PM> Uninstall-Package -Force AWSSDK

然后是:

PM> Install-Package AWSSDK -Version 1.5.12.1

然后仔细检查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>

现在,你的项目应该可以开始了。

尝试编辑.csproj文件,并从引用程序集awssdk的行中删除Version=1..5.9.1。