Could not load assembly error
Closed this issue · 2 comments
Visual Studio 2017 upgraded to SDK 2.1.101, since then getting the following error whenever I try to run dotnet ef migrations add (Dotnet ef seems to work fine and doesn't throw an error):
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions, Version=2.0.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)
at Microsoft.DotNet.Cli.Utils.DefaultCommandResolverPolicy.Create()
at Microsoft.DotNet.Cli.Utils.CommandResolver.TryResolveCommandSpec(ICommandResolverPolicy commandResolverPolicy, String commandName, IEnumerable`1 args, NuGetFramework framework, String configuration, String outputPath, String applicationName)
at Microsoft.DotNet.Cli.Utils.Command.Create(ICommandResolverPolicy commandResolverPolicy, String commandName, IEnumerable`1 args, NuGetFramework framework, String configuration, String outputPath, String applicationName)
at Microsoft.DotNet.Cli.Utils.Command.CreateDotNet(String commandName, IEnumerable`1 args, NuGetFramework framework, String configuration)
at Migrator.EF6.Tools.ProjectReader.ReadProject(Stream stream, String projectName, String projectPath)
at Migrator.EF6.Tools.ProjectReader.GetProject(String projectPath)
at Migrator.EF6.Tools.Executor..ctor(Boolean verbose, String connectionString, String providerName, String context)
at Migrator.EF6.Tools.CommonConfiguration.CreateExecutor()
at Migrator.EF6.Tools.MigrationsCommand.<>c__DisplayClass1_2.b__6()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Migrator.EF6.Tools.Program.Main(String[] args)
Right now, this tool works under SDK 1.0. You can download ".NET Core SDK 1.1.8" from here: https://www.microsoft.com/net/download/all. Of course, you can also have SDK 2.0 installed.
I should probably mention this somewhere in the README. I was planing to update it, but faced some related problems.
Actually I had 1.1.8 installed, and my solution was working fine till yesterday. I just realized that I changed one of the referenced projects to netstandard2.0 and upgraded the Microsoft.AspNetCore.Mvc.DataAnnotations
package to 2.0.3 from 2.0.0. Further, in my migrations project which targets net47, I updated Microsoft.AspNetCore.Hosting.Abstractions
to 2.0.2 from 2.0.1. If I revert the Data Annotations and the hosting abstractions packages to the original, it works fine. Without changing the SDK (which is currently at 2.1.101).