在我的项目中,我需要同时使用Castle.Windsor和Moq dll。 Windsor要求Castle.Core也在项目中引用。
当我尝试使用Castle.Core中的方法时,问题就出现了:
Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(...);
问题1: 如果我使用NET40文件夹中的Moq.dll,我得到了错误“类型'Castle.DynamicProxy.Generators.AttributesToAvoidReplicating'存在于'... \ Windsor \ dotNet40 \ Castle.Core.dll'和'... \ MOQ \ NET40 \ Moq.dll'“
Problem2: 如果我使用“NET40-RequiresCastle”文件夹中的Moq.dll,这在逻辑上是我的情况,我得到版本冲突 - Moq.dll使用Castle.Core,Version = 2.5.0.0,但Windsor使用Castle.Core,版本= 2.5 .1.0
答案 0 :(得分:8)
使用装配绑定可以解决问题 - 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>