如何解决Castle.Core程序集的Castle.Windsor和MoQ版本冲突 [英] How to resolve Castle.Windsor and MoQ version conflicts for Castle.Core assembly

查看:322
本文介绍了如何解决Castle.Core程序集的Castle.Windsor和MoQ版本冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我需要同时使用Castle.Windsor和Moq dll.温莎要求在项目中也引用Castle.Core.

In my project I need to use simultaneously Castle.Windsor and Moq dlls. Windsor requires Castle.Core also to be referenced in the project.

当我尝试使用Castle.Core中的方法时,问题开始了: Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(...);

Problem starts when I try to use methods from Castle.Core: Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(...);

问题1: 如果我从NET40文件夹中使用Moq.dll,则会生成错误消息"... \ Windsor \ dotNet40 \ Castle.Core.dll"和"... \中都存在类型'Castle.DynamicProxy.Generators.AttributesToAvoidReplicating'. MoQ \ NET40 \ Moq.dll'"

Problem1: If I use Moq.dll from NET40 folder, I got built error "The type 'Castle.DynamicProxy.Generators.AttributesToAvoidReplicating' exists in both '...\Windsor\dotNet40\Castle.Core.dll' and '...\MoQ\NET40\Moq.dll'"

问题2: 如果我在逻辑上根据情况从"NET40-RequiresCastle"文件夹中使用Moq.dll,则发生版本冲突-Moq.dll使用Castle.Core,版本= 2.5.0.0,而Windsor使用Castle.Core,版本= 2.5 .1.0

Problem2: If I use Moq.dll from "NET40-RequiresCastle" folder, which is logically in my situation, I got versions conflict - Moq.dll uses Castle.Core, Version=2.5.0.0, but Windsor uses Castle.Core, Version=2.5.1.0

推荐答案

可以使用程序集绑定解决问题- App.config:

Problem can be solved using assembly binding - App.config:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" />
    <bindingRedirect oldVersion="1.0.0.0-2.5.0.0" newVersion="2.5.1.0" />
  </dependentAssembly>
</assemblyBinding>

这篇关于如何解决Castle.Core程序集的Castle.Windsor和MoQ版本冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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