简体   繁体   中英

Visual Studio build error with “.Netstandard 2.0”?

I just added a library to my WPF project. The library dependencies are framework4.6 and .netstandard 2.

When I tried to build the project I got this error:

Microsoft.NET\\Framework\\v4.0.30319\\Microsoft.WinFx.targets(268,9): error MC1000: Unknown build error, 'Could not load type 'System.Object' from assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' because the parent does not exist.'

I have imported netstandard nuget package in my project. I tried to add a reference to netstandard, however, I could not find it in the list of assemblies so I browsed to the location and added the reference. Yet when I try to compile the project I get the same error. Any ideas on this error would be highly appreciated.

In order to target .netstandard 2.0 with standard framework, you must target at least .net 4.6.1 as shown in the following chart.

https://docs.microsoft.com/en-us/dotnet/standard/net-standard

Which specific library did you add?

I solved the same problem (against .NET 4.7.2 and Visual 15.8.x) by :

  • removing the 2013 directive : <ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>
  • removing the reference to netstandard.dll from the project.

I also ran a nuget package reinstall because my package versions were mixed between 4.6.2 and 4.7.2 :

  • Update-Package -Reinstall -Project MyProject

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM