core icon indicating copy to clipboard operation
core copied to clipboard

You must add a reference to assembly netstandard, Version=2.0.0.0

Open rosieks opened this issue 9 years ago • 21 comments

Hi, I have created new asp.net core application that's based on .NET Framework 4.6.1 and it doesn't build on my build server. Below is error message that I receive:

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'.

What should I do to solve that issue?

rosieks avatar Aug 17 '17 17:08 rosieks

I have a 100% .net core 2.0 project, originally 1.1, and I'm getting something similar.

Error CS0012 The type 'DbConnection' 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'.

samcov avatar Aug 18 '17 01:08 samcov

I just noticed that switching to 2.0 didn't upgrade the csproj, it looks like this,

<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>

Should I just change it there, or is there a way to do it in VS2017?

samcov avatar Aug 18 '17 02:08 samcov

hi @rosieks

I have a similar problem, and I remove the RuntimeFrameworkVersion, and the problem was fixed.

Try to remove <RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion> or <NetStandardImplicitPackageVersion section in the csproj.

alyiox avatar Aug 18 '17 02:08 alyiox

I have that problem for project that target version 2.0 from beginning.

rosieks avatar Aug 18 '17 06:08 rosieks

@qqbuby - I didn't see your response, so I just replaced the old version with 2.0.0 and everything worked.

However, if what you said is true, maybe those sections are no longer needed, but if there, must target the correct version.

Either way, people upgrading will likely be confused because the process misses those things.

samcov avatar Aug 18 '17 06:08 samcov

It looks like build server just lack Visual Studio 15.3

rosieks avatar Aug 18 '17 07:08 rosieks

@qqbuby this didn't work for me, and I am still being asked to add a reference. Is anybody still experiencing this during upgrade?

diegofal avatar Sep 13 '17 16:09 diegofal

Should we provide two versions, 1.0 and 2.0?

Best, Regards Roy Xu

On Aug 20, 2017, at 17:54, grokky1 [email protected] wrote:

I have the same problem. The upgrade guide does not cover this problem.

I am not using RuntimeFrameworkVersion or NetStandardImplicitPackageVersion. I hope someone from the dotnet team will address this problem.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

alyiox avatar Sep 13 '17 19:09 alyiox

What is the solution for this? I'm getting it in lots of projects now. For example, https://github.com/Arch/UnitOfWork is supposed to work with netcore 20. When I clone and build that repo, it complains about references to System.Data and System.Text.RegularExpressions as well as DbConnection. ex:

Severity Code Description Project File Line Suppression State Error CS0012 The type 'DbConnection' 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'. Microsoft.EntityFrameworkCore.UnitOfWork C:\Users\redwards\Downloads\UnitOfWork-2.0.1\src\Microsoft.EntityFrameworkCore.UnitOfWork\UnitOfWork.cs 48 Active

redwards510 avatar Sep 18 '17 21:09 redwards510

Add System.Data to your reference. It solve my problem.

risurina avatar Nov 29 '17 16:11 risurina

I had the same issue and when I upgraded VS2017 Enterprises IDE to version 15.5.5 it has been resolved magically.

sudheerah avatar Jan 29 '18 03:01 sudheerah

this code worked for me

<ItemGroup>
   <PackageReference Update="Microsoft.NETCore.App" Version="2.0.0" />
 </ItemGroup>

masaab avatar Jan 29 '18 11:01 masaab

I am still facing the same issue even after adding the

OR 2. 1.0.4 removed in csproj file. OR 2. OR 3.

Any help ??

vs6681 avatar Feb 09 '18 12:02 vs6681

solution that worked for me "upgrading target framework to 4.7.1" with out changing any other configuration

narinderparmar avatar Mar 07 '18 10:03 narinderparmar

I have created a new asp.net standard Library that is based on .NET Framework 4.6.2 and it doesn't build on my build server. Below is error message that I receive the same error: You must add a reference to assembly netstandard

akagGt avatar Mar 29 '18 14:03 akagGt

In my case the same issue was caused by xUnit - it turned out that xUnit requires .NET Core build tools. More details in this answer.

QtRoS avatar Sep 04 '18 15:09 QtRoS

I having same issue while running uwp Xamarin project in windows emulator

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'.

kamalkumar1 avatar Dec 24 '18 04:12 kamalkumar1

you are targeting different version of dll In my case the error was

Error CS0012 The type 'Task<>' 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'. EboIotEdgeConnector.Extension D:\projects\EboIoTEdgeConnector-master\EboIotEdgeConnector.Extension\RetainedMqttMessageHandler.cs

I ) change the IMqttServerStorage to MQTTnet.Server.IMqttServerStorage 2) remove the reference and of net461 version and add the reference from \packages\MQTTnet.2.8.4\lib\netstandard2.0 Rebuild the solution the issue will be resolved

AdilTalkpool avatar Jan 14 '19 06:01 AdilTalkpool

hi @rosieks

I have a similar problem, and I remove the RuntimeFrameworkVersion, and the problem was fixed.

Try to remove <RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion> or <NetStandardImplicitPackageVersion section in the csproj.

Thanks

jigarce avatar Jan 22 '19 07:01 jigarce

the same problem with teamcity build

fengbujue2022 avatar Jan 29 '19 11:01 fengbujue2022