c# - I write a test case in Aspnetboilerplate application. when run the test case It gives error about Unable to resolve dependencies


Keywords:c# 


Question: 

I get this error after running a test case in C# Aspnetboilerplate application. there is a problem with Castle.Core package. How would I fix this error?

Could not load file or assembly 'Castle.Core, Version=4.1.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) [2/28/2018 10:10:42 AM Informational] [xUnit.net 00:00:01.3681076]
-------- System.IO.FileLoadException : Could not load file or assembly 'Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) [2/28/2018 10:10:42 AM Informational] [xUnit.net 00:00:01.3759779] Stack Trace:


1 Answer: 

This a general dependency management issue that can arise when working with NuGet!

Try adding the required assembly version redirects to App.config or Web.config. (Sometimes, NuGet does this automatically for you sometimes you need to manually do that) See .

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>