Unity 5.2 Universal 10 Build Bug?

I’ve been trying to get a Windows 10 UAP build of our game working which uses some of the XML classes found in System.XML. The game runs fine in editor with no errors but when I go to make a Windows Universal 10 XAML build I get this error:

The type ‘XmlDocument’ exists in both ‘System.Xml.XmlDocument, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ and ‘WinRTLegacy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’

Is there anyway to work around this?

It’s a known bug that will be fixed in the first 5.2 patch release.

This happens due to the fact that these APIs weren’t available on Windows 8.1, so we’ve implemented them ourselves. However, Microsoft added them back with Windows 10.

The only workaround I can offer is to compile the offending code to a separate DLL and drop it into your project.

If you don’t have a lot of code that uses these conflicting classes, you could make this workaround:

  1. Build an empty Unity project for Windows 10, find WinRTLegacy.dll in the built Visual Studio project.
  2. Drop WinRTLegacy.dll into your normal Unity project (Plugins/WSA/). Mark it as “don’t process” in Unity.
  3. Add a file named csc.rsp directly in your Assets folder and put this line in it: /reference:WinRTLegacyTMP=Assets/Plugins/WSA/WinRTLegacy.dll
  4. In scripts that use conflicting classes, at the very top, add:

#if NETFX_CORE
extern alias WinRTLegacyTMP;
#endif

  1. In each file that uses conflicting classes for every conflicting class, also add these after other “using” statements:

#if NETFX_CORE
using ConflictingClassName = WinRTLegacyTMP::Full.Namespace.ConflictingClassName;
#endif

It’s not pretty, but if you need to build it and cannot wait for the fix, it’s better than nothing.

What do you make of this one? I’m using VS2015 that came installed with 5.2 (But it wasn’t in the list of script editors so I had to browse for it, if that the problem?)

Could not start compilationException: ‘UnionMetadata\Windows.winmd’ not found, do you have Windows UAP SDK installed?
UnityEditor.Scripting.Compilers.MicrosoftCSharpCompiler.FillNETCoreCompilerOptions (WSASDK wsaSDK, System.Collections.Generic.List`1 arguments, System.String& argsPrefix) (at C:/buildslave/unity/build/Editor/Mono/Scripting/Compilers/MicrosoftCSharpCompiler.cs:184)
UnityEditor.Scripting.Compilers.MicrosoftCSharpCompiler.StartCompiler () (at C:/buildslave/unity/build/Editor/Mono/Scripting/Compilers/MicrosoftCSharpCompiler.cs:291)
UnityEditor.Scripting.Compilers.ScriptCompilerBase.BeginCompiling () (at C:/buildslave/unity/build/Editor/Mono/Scripting/Compilers/ScriptCompilerBase.cs:47)
UnityEditor.HostView:OnGUI()

Try to create Universal Windows App from Visual Studio 2015, probably it doesn’t contain the required addon.

1 Like

That was it, thanks

Thanks for the info and workarounds, is there a release date or window for the first 5.2 patch?

On another thread they said that maybe on 2015-09-21.

Hello there, I have the same issue with AirBiscuit building from Unity 5.2.1f1 for Windows Universal 10.

How do you mean by the quoted solution? How can I create Universal Windows App from Visual Studio 2015?

I have opened VS2015 project file, press Start (build), and then I get this message.

A project with an Output Type of Class Library cannot be started directly.
In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.

Thanks!