程序集引用与找到的程序集定义不匹配

本文关键字:程序集 定义 不匹配 引用 | 更新日期: 2023-09-27 18:28:02

当我运行c#应用程序时,使用Assembly Binding日志查看器检查导致FileNotFoundException错误的原因时,我在其中一个错误日志文件中得到了以下信息:

LOG: Post-policy reference: msvcm90, Version=9.0.30729.4974, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    LOG: Did not find assembly in DEVOVERRIDE path C:'Documents and Settings'All Users'Application Data'Red Gate'.NET Reflector'DevPath
    LOG: GAC Lookup was unsuccessful.
    LOG: Attempting download of new URL file:///F:/Stuff/Muaz/Programming/C#/Spatial and Temporal Research/Spatial and Temporal Research/bin/Debug/msvcm90.DLL.
    LOG: Assembly download was successful. Attempting setup of file: F:'Stuff'Muaz'Programming'C#'Spatial and Temporal Research'Spatial and Temporal Research'bin'Debug'msvcm90.dll
    LOG: Entering run-from-source setup phase.
    LOG: Assembly Name is: msvcm90, Version=9.0.30729.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    WRN: Comparing the assembly name resulted in the mismatch: Revision Number
    ERR: The assembly reference did not match the assembly definition found.
    ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

我尝试在app.config文件中直接使用绑定:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <runtime>
        <assemblyBinding>
            <dependentAssembly>
                <assemblyIdentity name="msvcm90"
                                  publicKeyToken="b03f5f7f11d50a3a" />
                <bindingRedirect oldVersion="9.0.30729.4974"
                                 newVersion="9.0.30729.1"/>
            </dependentAssembly>        
        </assemblyBinding>
    </runtime>
</configuration>

但是发生了相同的错误。我试图搜索dll文件msvcm90,但找不到版本9.0.30729.4974(可能是因为它很旧)。有其他方法可以解决这个问题吗?谢谢

程序集引用与找到的程序集定义不匹配

您依赖VS2008附带的托管C运行时支持DLL。您提供的版本非常旧,不属于您放置的目录,需要将其部署到Windows并行缓存(c:''Windows''winsxs)中。先删除文件,你可能会很幸运。

最好的做法是向使用此支持DLL的产品或DLL的所有者询问正确的安装过程。接下来最好的事情是安装VC++支持的运行库,您可以从这里下载安装程序。我不知道它的版本是否正确,自从它发布以来,已经有很多安全补丁了。安装后运行Windows Update。