Search Issue Tracker

Third Party Issue



Found in






Issue ID




Packages are inconsistent with the project API Compatibility Level setting when set to .NET Standard 2.1



How to reproduce:
1. Open the user's attached project
2. In the Project window, navigate to Packages -> Examples.Common.Unions -> CodeGen.Genesis
3. Open the script UnionGenerator.cs
4. At line 193, insert the two following lines of code: var hash = new System.HashCode(); hash.Add(0);
5. Save the script file
6. In the Project window, navigate to Assets -> Examples
7. Select the Asset "UnionGenesisSettings"
8. In the Inspector window, click the "Generate" button
9. Observe the Console

Expected result: no exceptions are thrown
Actual result: an exception is thrown: "System.ComponentModel.Win32Exception (0x80004005): ApplicationName='dotnet' <...>"

Reproducible with: 2019.4.33f1, 2020.3.24f1, 2021.2.6f1, 2022.1.0b2

  1. Resolution Note:

    .asmdefs with platform "Editor" only are always compiled against the .net framework profile. To solve the issue, the .asmdef platform should be set as "all platform", and use a define constraint to avoid having it deployed with player builds (adding "UNITY_EDITOR" to the list of define constraints). This way, Unity will compile it as a .NET standard 2.1, and both the Mono runtime and .NET core will succeed in redirecting "System.HashCode, netstandard" to its correct implementation.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.