Unity 3D UWP build fails: System.Xml cannot be fou

2019-08-12 02:43发布

I am trying to build my project for UWP, HoloLens to be specific. I am getting XML data from the web and parse that using NewtonSoft.JsonConvert.SerializeXmlNode (XmlNode node) (returns string). Here's a list of stuff you need to know and stuff that I tried already:

My Unity version is 2018.1.3f1, Scripting Runtime Version is .NET 4,x Equivalent, Scripting Backend is Mono, API Comp. Lvl is .NET 4.x as well.

The exact error message: Assets\Scripts\RestManager.cs(62,23): error CS7069: Reference to type 'XmlNode' claims it is defined in 'System.Xml', but it could not be found

I double checked the necessary includes and also checked for a similar error described here: https://github.com/OmniSharp/omnisharp-vscode/issues/1986

What I want to do works both in a standalone build and the editor.

Any help is much appreciated!

----- Edit: Update -----

Hey,

I am still trying to get this to work and these errors showed up after my last attempt to add the package to a XAML-based built from Unity:

Install-Package : NU1107: Version conflict detected for System.Collections. Reference the package directly from the project to resolve this issue. HoloEPA -> Microsoft.NETCore.UniversalWindowsPlatform 5.0.0 -> System.Net.Sockets 4.0.0 -> runtime.win.System.Net.Sockets 4.3.0 -> System.Collections (>= 4.3.0) HoloEPA -> Microsoft.NETCore.UniversalWindowsPlatform 5.0.0 -> Microsoft.NETCore.Runtime 1.0.0 -> Microsoft.NETCore.Runtime.CoreCLR-arm 1.0.0 -> System.Collections (= 4.0.10). At line:1 char:1 + Install-Package System.Xml.XmlDocument -Version 4.3.0 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Package restore failed. Rolling back package changes for 'HoloEPA'. At line:1 char:1 + Install-Package System.Xml.XmlDocument -Version 4.3.0 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

标签: unity3d uwp
1条回答
迷人小祖宗
2楼-- · 2019-08-12 03:45

XmlNode is not part of .NET Core (which is used by UWP). It works in the editor or standalone builds because they are using a different version of .NET (depending on your version of Unity, it could be using Mono or .NET 2.X or 4.X).

Add this package to your Visual Studio project using NuGet, and you will be able to use XmlNode again. This assembly will define the XmlNode class under the System.Xml namespace, as expected.

查看更多
登录 后发表回答