job.answiz.com
  • 0
Votes
name

I am getting the following exception while referencing a .Net standard 2.0 project from WPF application developed using .Net framework 4.6.1 project

Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.'

Any suggestions?

 

As of today (using VisualStudio 2017 15.8.4) this still seems to be a common problem:

Transitive dependencies are not correctly handled with the package management format which uses the packages.config file to reference dependencies.

The problem is that VisualStudio 2017 still uses this old package management format by default when you create a new WPF desktop project.

Solution

The solution is to migrate the project references from packages.config file to the new PackageReference node in the .csproj project file.

VisualStudio can do this migration automatically for you. The migration is documented here:

https://docs.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference

Please note that there is a known issue:

The Migrate packages.config to PackageReference... option is not available in the right-click context menu until NuGetwas initialized.

Another option if your project does not have any package references at all is to change the setting of RestoreProjectStyle to PackageReference in your .csproj file.

https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#using-packagereference-for-a-project-with-no-packagereferences

I hope this helps.

  • 0
Reply Report