Add a reference to assembly netstandard error with .NET Framework 4.6.1 project

Wonderful World 21 Reputation points
2022-04-27T01:40:49.367+00:00

A
.NET Framework 4.6.1
project which has a reference to a nuget package built with
.netstandard2.0
is no more building. The following is the error. It is around the time when the IT Department uninstalled
.net core 2.0 SDK
from the build machine.

I added
<Reference Include="netstandard" />
to the project. The following error goes away but gives another error.

How can I fix this problem? Will installing
.net core 3.1 SDK
solve the problem?

"c:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/MSBuild/Current/Bin/msbuild.exe" /p:Configuration=Release /verbosity:quiet /p:Platform="x86" /clp:ErrorsOnly /nologo /noautorsp /m

26-Apr-2022 18:13:55 C:\bamboo6104\xml-data\build-dir\BAM-PF1818-JOB1\MyProject\Services\SubscriptionProvider.cs(37,41): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [C:\bamboo6104\xml-data\build-dir\BAM-PF1818-JOB1\MyProjectFolder\MyProject.csproj]
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,370 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,238 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,985 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 55,686 Reputation points
    2022-04-27T15:58:19.683+00:00

    .net framework 4.6.1 does not fully support .netstandard 2.0. most likely your nuget package got updated. as 4.6.1 is out of support, so you should upgrade to 4.8 in any event. .net 4.8 has complete support of .netstandard 2.0

    .net 3.1 will be out of support in December, so you might as well install .net 6 if you want to create and build .netstandard 2.0 libraries.

    1 person found this answer helpful.
    0 comments No comments