Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fix "type exists in both assemblies" failure when using DynamicProxy types in an assembly referencing NSubstitute?
    primarykey
    data
    text
    <p>I have an application that uses <a href="http://www.castleproject.org/projects/dynamicproxy" rel="nofollow">DynamicProxy</a> 3.1 to do runtime interception. I have a test assembly that uses <a href="https://github.com/nsubstitute/NSubstitute" rel="nofollow">NSubstitute</a> for mocking. I just wrote some "integration" tests against my fully bootstrapped container (StructureMap using <code>InterceptWith</code> to do the interception) so that I can assert that certain types coming out of the container are proxied properly.</p> <pre><code>[Subject(typeof(RobotBoard))] public class When_resolving_an_intercepted_type : WithContainer&lt;IRobotBoard&gt; { It should_have_recovery = () =&gt; Subject.ShouldHaveInterceptor&lt;RecoveryInterceptor&gt;(); } public static class TestExtensions { public static void ShouldHaveInterceptor&lt;T&gt;(this object obj) where T : IInterceptor { ((IProxyTargetAccessor)obj) .GetInterceptors() .ToList() .Exists(x =&gt; x is T) .ShouldBeTrue(); } } </code></pre> <p>However, I get this error, indicating that DynamicProxy references are <em>inside</em> the NSubstitute assembly, too! (it appears to be ilmerged).</p> <pre><code>Error 11 MyCompany.MyModule.Specifications D:\code\source\tests\When_resolving_an_intercepted_type.cs The type 'Castle.DynamicProxy.IProxyTargetAccessor' exists in both 'd:\code\packages\Castle.Core.3.1.0\lib\net40-client\Castle.Core.dll' and 'd:\code\packages\NSubstitute.1.4.2.0\lib\NET40\NSubstitute.dll' </code></pre> <p>Is there anyway around this conflict?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload