Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

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

Discussion in 'Experimental Scripting Previews' started by a-shoulson, Jul 15, 2017.

  1. a-shoulson

    a-shoulson

    Joined:
    Jun 24, 2015
    Posts:
    8
    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?
     
  2. a-shoulson

    a-shoulson

    Joined:
    Jun 24, 2015
    Posts:
    8
    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.
     
  3. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    Is this another Reference Assembly? An assembly that references another but has no functionality? If so Unity doesn't support those.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    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.
     
  5. a-shoulson

    a-shoulson

    Joined:
    Jun 24, 2015
    Posts:
    8
    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?
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    It is not in the Unity 2017.2 beta releases yet, but we're hoping to make it before the final release.
     
  7. j-borden

    j-borden

    Joined:
    Mar 3, 2015
    Posts:
    21
    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)
     
    benzsuankularb likes this.