Standard: UWP SDK 16267 - The type 'Object' is defined in an assembly that is not referenced

Created on 12 Sep 2017  ·  9Comments  ·  Source: dotnet/standard

I am trying to UWP to work with .NET Standard 2.0, and am being presented with the following error when trying to build the project:

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'

I reported this as a comment on issue #391 and have been asked to open this as a new issue due to being related to UWP.

I am running Visual Studio 2017 15.4 Preview 2 (problem was also present on Preview 1). I also have the Insider SDK 16267 installed - According to the following blog post UWP & .NET Standard 2.0 are supposed to work together:
https://blogs.msdn.microsoft.com/dotnet/2017/08/25/uwp-net-standard-2-0-preview

In the comments of that blog post, people were getting issues similar to this (which I also had originally)

error : Project ‘.csproj’ targets ‘.NETStandard,Version=v2.0’. It cannot be referenced by a project that targets ‘UAP,Version=v10.0.16267

The fix was to install the .NET Standard SDK 2.0.2 which is available from:
https://aka.ms/ns2x64
https://aka.ms/ns2x86

Now, VS attempts to build the project, but fails with the error above that Object is defined in an un-referenced assembly.

Copied in those relevant from the original comment on issue #391
cc: @weshaggard @joperezr @nattress

Most helpful comment

use the netstandard.dll from the either following locations and put it into a local folder of your choice and insert the "ItemGroup" below at the end of your .csproj file

locations to look for DLL ;
`C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll or from the .NET Core 2.0 SDK you can find it C:\Program Files\dotnet\sdk\2.0.0\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll

`

<ItemGroup> <Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"> <HintPath>..\Workaround\netstandard.dll</HintPath> <Private>True</Private> </Reference> </ItemGroup>

All 9 comments

use the netstandard.dll from the either following locations and put it into a local folder of your choice and insert the "ItemGroup" below at the end of your .csproj file

locations to look for DLL ;
`C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll or from the .NET Core 2.0 SDK you can find it C:\Program Files\dotnet\sdk\2.0.0\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll

`

<ItemGroup> <Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"> <HintPath>..\Workaround\netstandard.dll</HintPath> <Private>True</Private> </Reference> </ItemGroup>

@amasoumi THanks - That works - pretty obvious now you mention it :)

@daveh101 , no problem, don't forget to give me rating 👍

While that might workaround this issue it isn't the correct solution. You might be getting lucky that the net461 netstandard.dll works in UWP but that is definitely not the one that should be used. There is a netstandard.dll that is specific to UWP and it should be in the meta-package Microsoft.NETCore.UniversalWindowsPlatform.

@joperezr @nattress do you guys have any ideas why he might not be getting the netstandard.dll referenced automatically?

@daveh101 can you tell us what version of Microsoft.NETCore.UniversalWindowsPlatform package you are referencing?

@weshaggard I have 2 solutions that I am working on, typically both on different versions, 5.3.2 and 5.4.0

It doesn't work with either of these. There doesn't appear to be any pre-release version that can be used either

since you need to have NETStandard.Library.NETFramework.2.0.0-preview2-25405-01 to build references to the API and one of its dependency is NETStandard.Library (>= 2.0.0-preview2-25401-01) for some reason it will points to a different version of netstandard dll even though you upgraded to the latest stable version of NETStandard.Library which is 2.0.0.0, so I think for now this is one option,
however I agree that this is not a permeant solution until they release a stable version of NETStandard.Library.NETFramework

@amasoumi NETStandard.Library.NETFramework is about .NET Framework and not UWP some of it might work but there will definitely be some issues with it as you start to use more of the types from netstandard.

@daveh101 You will need to use a 6.0.0 version of the Microsoft.NETCore.UniversalWindowsPlatform package to be able to correctly consume .NET Standard 2.0 assets. It doesn't look like we have a preview of it on nuget yet but we do have a version on our dev build myget feed. https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.NETCore.UniversalWindowsPlatform/6.0.0

For reference, I had the same issue, even after updating Microsoft.NETCore.UniversalWindowsPlatform to the newest version (which is 6.0.1 at the moment)

Turns out you have to set the UWP project to target the fall creators update. Maybe that saves someone else time when they come across the same problem, because the error message is certainly very misleading.

Was this page helpful?
0 / 5 - 0 ratings