0
votes

I have created some helper libraries (NuGet) and these work fine in my various .Net FullFramework and .Net Core applications.

However, when I add them to a particularly complicated Asp.Net MVC (.Net 4.7.2) web application, I get the following errors:

  1. The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to the assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=....
  2. The type 'System.IComparable' is defined in an assembly that is not referenced. You must add a reference to the assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=....
  3. The type 'System.IFormattable' is defined in an assembly that is not referenced. You must add a reference to the assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=....
  4. The type 'System.IConvertable' is defined in an assembly that is not referenced. You must add a reference to the assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=....
  5. The type 'System.ValueType' is defined in an assembly that is not referenced. You must add a reference to the assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=....

In the "output" window, the last few are showing as:

ASPNETCOMPILER : error CS0455: Type parameter 'T' inherits conflicting constraints 'System.IFormattable' and 'System.IComparable'

My NuGet packages (A, B, C D and E) themselves have the following NuGet packages:

PackageA - <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>

  • Microsoft.CodeAnalysis.FxCopAnalyzers 2.98
  • NETStandard.Library 2.0.3
  • StyleCop.Analyzers 1.1.118

PackageB - <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>

  • PackageA
  • Microsoft.CodeAnalysis.FxCopAnalyzers 2.98
  • NETStandard.Library 2.0.3
  • Newtonsoft.Json 12.0.3
  • StyleCop.Analyzers 1.1.118
  • System.Configuration.ConfigurationManager 4.7.0
  • System.Data.SqlClient 4.8.1

PackageC - <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>

  • PackageB
  • Microsoft.CodeAnalysis.FxCopAnalyzers 2.98
  • NETStandard.Library 2.0.3
  • StyleCop.Analyzers 1.1.118
  • System.Diagnostics.EventLog 4.7.0

PackageD - <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>

  • PackageC
  • Microsoft.CodeAnalysis.FxCopAnalyzers 2.98
  • NETStandard.Library 2.0.3
  • StyleCop.Analyzers 1.1.118
  • System.Runtime.Caching 4.7.0

PackageE - <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>

  • PackageD
  • Microsoft.CodeAnalysis.FxCopAnalyzers 2.98
  • NETStandard.Library 2.0.3
  • StyleCop.Analyzers 1.1.118

I've tried the following, either all together, or one at a time...no luck.

  1. Added a NuGet reference to NETStandard.Library (2.0.3) and also tried 2.0.0 (because that was what was specifically asked for).
  2. Added <Reference Include="netstandard" /> to my *.csprog file
1

1 Answers

0
votes

Finally, solved this by changing my web.config from

<compilation debug="true" targetFramework="4.7.2" />

to

<compilation debug="true" targetFramework="4.7.2" > 
  <assemblies>
    <add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/> 
  </assemblies>
</compilation>

Thanks to this post by David Sekar.