12
votes

I have a Asp.Net Core project targeting .NET 462 and it was working with Asp.Net Core version 1.0.1. After upgrading to "1.1.0" I got this error:

FileLoadException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

project.json

"dependencies": {
    "AspNet.Mvc.TypedRouting": "1.2.0",
    "AutoMapper": "5.1.1",
    "AutoMapper.Extensions.Microsoft.DependencyInjection": "1.1.2",
    "BundlerMinifier.Core": "2.2.306",
    "JetBrains.Annotations": "10.2.1",
    "libphonenumber-csharp": "7.7.4",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
    "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0",
    "Microsoft.AspNetCore.Authentication.Google": "1.1.0",
    "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0",
    "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
    "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0",
    "Microsoft.AspNetCore.Session": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.EntityFrameworkCore": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
    "Microsoft.Extensions.Configuration": "1.1.0",
    "Microsoft.Extensions.Configuration.Abstractions": "1.1.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.1.0-preview4-final",
    "MotleyFlash": "0.3.0",
    "MotleyFlash.AspNetCore.MessageProviders": "0.2.0",
    "MotleyFlash.AspNetCore.ViewHelpers": "0.2.0",
    "SendGrid.NetCore": "1.0.0-rtm-00002",
    "System.Interactive.Async": "3.1.0",
    "Twilio": "4.7.2"
},
"frameworks": {
    "net462": {
        "dependencies": {
            "TaxiGun.Server.IdentityServer.Data": {
                "target": "project"
            },
            "TaxiGun.Server.Services": {
                "target": "project"
            }
        }
    }
},

When I take a look at on build output folder, I can see all the libraries in a proper version except "Microsoft.EntityFrameworkCore.SqlServer": Microsoft.EntityFrameworkCore.SqlServer

I think it is causing the problem. But I just can not figure out why the version is wrong? Is it because the nuget package has a wrong version inside?

2
I have deleted local Nuget repository and now I get this error: Could not find a part of the path 'C:\Users\Admin\.nuget\packages\Microsoft.EntityFrameworkCore.SqlServer\1.0.1\lib\net451\Microsoft.EntityFrameworkCore.SqlServer.dll'. I do not reference 1.0.1 version anywhere. Strange.Skorunka František
Try deleting your project.lock.json file and restore the packages againJérôme MEVEL
Yes, I tried, it did not help. What actually helped is strange: I jhave created a new AspNET Core project, referenced my other project, update to the latest libraries and then removed the new project and he we go, the "old" project is now working too.Skorunka František
I see the problem in your project.json now. When updating libraries using NuGet manager, all dependencies are moved to the dependencies section, even the ones that weren't and shouldn't like the tools (eg: Microsoft.AspNetCore.Razor.Tools or Microsoft.EntityFrameworkCore.Tools)Jérôme MEVEL
In other projects I have Tools in Dependencies and it works: "Microsoft.AspNetCore.Razor.Tools": { "version": "1.0.0-preview2-final", "type": "build" }.Skorunka František

2 Answers

15
votes

Complete project references clean-up solved my problem.

  1. Delete all bin/obj folders
  2. Delete all project.lock.json files
  3. Delete local Nuget repository cache (computer one)
  4. Remove all references from project.json file and add only required ones (with the help of R#)
  5. nuget udpate, dotnet restore = project is running

When I'm thinking about it again, maybe only point 4 was important?

-2
votes

updated Pomelo.EntityFrameworkCore.MySql in .csproj file to the latest version 3.1.1 to fix issue.