-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Describe the bug
After I have ported some class libraries to .NET Standard 2.0, I get the following error message when building a .NET Framework 4.8 project which references a .NET Standard 2.0 project:
The type 'System.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'.
After some investigation I found out that the build only fails when GenerateSerializationAssemblies is set to On and SGenUseProxyTypes is set to false in the .NET Framework project. When I set SGenUseProxyTypes to true or remove it the build succeeds.
I hope this is the right place for this bug report.
To Reproduce
- Create a new class library with .NET Framework 4.8 and rename the default class to
NetFramework - Add the following two lines to the *.csproj file of the .NET 4.8 project (to the first PropertyGroup)
<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
<SGenUseProxyTypes>false</SGenUseProxyTypes> - Create a new class library with .NET Standard 2.0 and rename the default class to
NetStandard - In the .NET 4.8 Project add a reference to the .NET Standard 2.0 class library
- Create a public property in the .NET 4.8 class library with the type
NetStandard
public NetStandard.NetStandard NetStandard { get; set; } - Build the solution in visual studio -> build fails
Attached you'll find a small repro with both projects.
Exceptions
CS0012 The type 'System.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'
Further technical details
- dotnet --info:
.NET SDK (reflecting any global.json):
Version: 6.0.101
Commit: ef49f6213a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.101\
Host (useful for support):
Version: 6.0.1
Commit: 3a25a7f1cc
- I am using Visual Studio Enterprise 2022 (17.0.4
DotNetStandard_SGenUseProxyTypes.zip
)