两个不同的程序集版本“定位的程序集的清单定义与程序集引用不匹配" [英] Two different assembly versions "The located assembly's manifest definition does not match the assembly reference"

查看:22
本文介绍了两个不同的程序集版本“定位的程序集的清单定义与程序集引用不匹配"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目需要使用 NHibernate 的 Mysql 连接器 (Mysql.Data.dll).我还想在同一个项目中引用另一个项目 (Migrator.NET).问题是,即使 Migrator.NET 是使用特定版本 = false 的对 MySql.Data 的引用构建的,它仍然会尝试引用构建库的旧版本 MySql.Data 而不是仅使用那里的版本.. 我得到了标题中列出的异常:

I have a project that I am working on that requires the use of the Mysql Connector for NHibernate, (Mysql.Data.dll). I also want to reference another project (Migrator.NET) in the same project. The problem is even though Migrator.NET is built with the reference to MySql.Data with specific version = false, it still tries to reference the older version of MySql.Data that the library was built with instead of just using the version that is there.. and I get the exception listed in the title:

----> System.IO.FileLoadException:无法加载文件或程序集'MySql.Data,版本=1.0.10.1,文化=中立,PublicKeyToken=c5687fc88969c44d' 或它的依赖项之一.位于程序集的清单定义确实与程序集引用不匹配.(来自 HRESULT 的异常:0x80131040)

----> System.IO.FileLoadException : Could not load file or assembly 'MySql.Data, Version=1.0.10.1, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

我在主程序集中引用的版本是 6.1.3.0.如何让两个程序集合作?

The version I am referencing in the main assembly is 6.1.3.0. How do I get the two assemblies to cooperate?

对于那些指定程序集绑定重定向的人,我已经设置了:

For those of you specifying Assembly Binding Redirection, I have set this up:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-6.1.3.0" newVersion="6.1.3.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

我在另一个项目中引用了这个主程序集,但仍然遇到相同的错误.如果我的主程序集被复制到本地以供其他程序集使用,它会使用 app.config 中的设置还是必须将这些信息包含在引用我的主程序集的每个应用程序或程序集中?

I am referencing this the main assembly in another project and still getting the same errors. If my main assembly is copied local to be used in the other assembly, will it use the settings in app.config or does this information have to be included with every application or assembly that references my main assembly?

推荐答案

这是一个非常严重的版本不匹配.当版本差异如此之大时,bindingRedirect 将无济于事.顺便说一句,您弄错了,您希望 newVersion 与找到的那个相匹配.但不要去那里.

That's a pretty gross version mismatch. bindingRedirect is not going to help when the versions differ so much. You got it wrong btw, you'd want newVersion to match the one that was found. But don't go there.

查看 Migrator.NET 下载,我想我看到了问题.lib 文件夹包含真正 MySql.Data.dll 的旧版本,它可以在.NET 1.0 上运行.首先将其删除并尝试使用该程序集的第 6 版进行重建.祝你好运,我想你会需要它.

Looking at the Migrator.NET download, I think I see the problem. The lib folder contains a really old version of MySql.Data.dll, it was made to run on .NET 1.0. Start by zapping it and try to rebuild with version 6 of that assembly. Good luck, I think you'll need it.

这篇关于两个不同的程序集版本“定位的程序集的清单定义与程序集引用不匹配"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆