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

时间:2012-03-17 06:13:09

标签: c# file dll assemblies match

使用程序集绑定日志查看器检查运行c#应用程序时导致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文件中使用binding direct:

<?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(也许是因为它的旧)。还有其他方法可以解决这个问题吗?谢谢。

1 个答案:

答案 0 :(得分:1)

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

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