sarah daneshvar
sarah daneshvar

Reputation: 75

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.

Upvotes: 0

Views: 4987

Answers (2)

JB.
JB.

Reputation: 1110

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

Upvotes: 0

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93444

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://learn.microsoft.com/en-us/dotnet/standard/net-standard

Which specific library did you add?

Upvotes: 2

Related Questions