Search code examples
asp.netaspnetboilerplatecastleassembly-binding-redirect

Stuck in Entity Framework due to Castle.Core


I've followed the tutorial but it seems a bit outdated (ref. https://aspnetboilerplate.com/Pages/Documents/Articles/Introduction-With-AspNet-Core-And-Entity-Framework-Core-Part-1/index.html).

I build the program and then I do an Update-Database, but I get stuck on following error:

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)

First, I checked if I used the most recent version of .NET Core and then updated to latest (dotnet-sdk-2.1.202-win-x64.exe). Afterwards, I checked NuGet and I've got the most recent versions of Castle.Core, Castle.Facilities.Logging and Castle.Windsor.

I then tried following changes in the Entity Framework project, App.config file:

  1. I removed bindingRedirect from Castle.Core, making it:

    <dependentAssembly>
        <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
    </dependentAssembly>
    
  2. In NuGet, I've updated ABP and ABP Entity Framework from 3.8.1 to 3.8.2.

  3. Reloaded the DLLs for Castle.


Solution

  • When I ALSO removed the bindingRedirect from Castle.Core in the Core project, it started to work.

    <dependentAssembly>
        <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
    </dependentAssembly>