Hi,
I am trying to build a UWP app on Unity 2018.1.0f2 that consists of a UWP dll and a NetStandard dll. When I try to build in Unity, I get a bunch of error similar to:
“Assets\Scripts\CaptureScript.cs(45,29): 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…”
CaptureScript.cs calls APIs defined in the NetStandard dll and these errors seem to be triggered at every line where CaptureScript calls these APIs.
The player settings are set as below:
Scripting Runtime Version: .NET 4.x equivalent
Scripting Backend: .NET
Api Compatibility Level: .NET Standard 2.0
I have also tried to ‘Open C# Project’ from the Assets menu and I do see a reference to netstandard in that project.
So is using netstandard libraries in UWP not a supported scenario in Unity?
You can’t use .NET Standard libraries with .NET scripting backend. You’ll have to switch to IL2CPP.
Hi Tautvydas-Zilys,
Follow up question: I am now trying to build a standalone app with the same Universal DLL and NetStandard DLL. But on build I get the following error:
ArgumentException: The Assembly Windows.Foundation.UniversalApiContract is referenced by TestUWP (‘Assets/Plugins/TestUWP.dll’). But the dll is not allowed to be included or could not be found.
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List1[T] alreadyFoundAssemblies, System.String[ ] allAssemblyPaths, System.String[ ] foldersToSearch, System.Collections.Generic.Dictionary
2[TKey,TValue] cache, UnityEditor.BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:154)
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List1[T] alreadyFoundAssemblies, System.String[ ] allAssemblyPaths, System.String[ ] foldersToSearch, System.Collections.Generic.Dictionary
2[TKey,TValue] cache, UnityEditor.BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:160)
UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[ ] paths, System.String[ ] foldersToSearch, UnityEditor.BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:194)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
I have double checked that the Windows.Foundation.UniversalApiContract.winmd file exists in the C:\Program Files (x86)\Windows Kits\10\References\10.0.16299.0\Windows.Foundation.UniversalApiContract\5.0.0.0\ folder.
I have also tried to manually copy the Windows.Foundation.UniversalApiContract.winmd file into the Unity project assets folder but still get the same error.
Player Settings are as follows:
Scripting Runtime Version: .NET 4.x Equivalent
Scripting Backend: IL2CPP
Api Compatibility Level: .NET 4.x
Thanks,
I believe we currently don’t support calling into Windows Runtime (or using .winmd files in other words) on Windows Standalone player. You’ll have to mark “TestUWP.dll” as compatible with UWP player only.
We plan to implement this eventually, but we’re not there yet.
1 Like