Using .NET Standard DLL in Unity .NET 4.6, issue with enums

I’m adding a .NET Standard 1.3 DLL to my Unity project under the experimental .NET 4.6 profile. The DLL seems to work fine in general, but when I try to reference an enum defined in that netstandard DLL, I get the following error:

error CS0012: The type System.Enum' is defined in an assembly that is not referenced. Consider adding a reference to assembly System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

Manually adding the given reference to the C# project (as described here) allows me to build fine in Visual Studio, but this is presumably clobbered each time by the Unity project generation and the editor won’t let me proceed.

Any advice on how to move forward?

Just as an update, I explicitly added the given 4.6 Facade assembly to my project and can move forward and press play. I get an error that:

Loading script assembly “Assets/Assemblies/System.Runtime.dll” failed!

But I encounter no actual errors at runtime while using that enum from the netstandard DLL. It still seems like something is wrong here though.

Is this another Reference Assembly? An assembly that references another but has no functionality? If so Unity doesn’t support those.

Unity doesn’t support any version of .Net Standard in 2017.1. We’re working now on adding support for .Net Standard 2.0 and earlier, but it is not ready for release just yet.

Okay, thanks for the clarification! I had thought .NET 4.6 would include support for netstandard 1.3, but I’ll wait for the 2.0 support when it arrives. Is this something for 2017.2 or is it a longer timeframe?

It is not in the Unity 2017.2 beta releases yet, but we’re hoping to make it before the final release.

Just FYI, if you grab the System.Runtime.dll from Nuget, and your package is .NET Standard 1.3 or lower, it’s probable that things will work as long as you get all the packages from Nuget and throw them in there. I know for a fact that I am using a few .NET Standard 1.0 and .NET Standard 1.1 only dependencies in my library and they load just fine. My overall library is .NET Standard 1.4, though, so it fails (because it requires 4.6.1)

1 Like