XmlDocument .NET 2.1 Build Error

I am trying to use System.Xml, specifically I am trying to use XMLDocument.

using UnityEngine;
using System.Collections.Generic;
using System.IO;
using System.Xml;

public AssetReader : MonoBehaviour {

    // Asset list
    List<MyAsset> assetList = new List<MyAsset>();

    // The XmlDocument
    private XmlDocument xmldoc = null;

    // Path to our configuration XML file;
    private string configFilePath = "Assets/Resources/xmlConfig.xml";

    void Start() 
    {
        // Create a FileStream object to read in our configuration file
	    FileStream fs = new FileStream(configFilePath,FileMode.Open,FileAccess.Read,FileShare.ReadWrite);

        // Initialize our xmlDocument object and load the FileStream.
        xmldoc = new XmlDocument();
	     xmldoc.Load(fs);

        // Close the FileStream
        fs.Close();
    }

}

There is a lot carved out from actual code obviously but Ive carved it down to the simple initial declaration of the XmlDocument that breaks it. Everything works fine in the Unity iPhone editor, but when I try to build the XCode project I get a System Exception that System.Net.Sockets is a Unity iPhone Advanced Only feature.

What am I doing wrong here? Where am I attempting to use sockets? Or is this a bug?

Thanks in advance for any light you can shed on the matter.

–J

Are you sure that the error says sockets not

System, System.Xml and System.Net ?

Up to 1.5.1 neither System nor System.Xml could be used on Unity iPhone Basic, not due to UT deciding to do so (they only decided to add a clear error message so you are aware of it) but because you can no longer compile the application at all because the framework becomes to large by the iPhone SDKs requirement without stripping.

I’m using Unity iPhone (latest 1.6) and yes the error says Sockets, not XML. You should be able to reproduce the error in an empty unity iphone project. cut and paste my code to a script. You can even take out the entire Start funciton’s functionality. Just the XmlDocument declaration kills it but only on exporting the xcode project.

Can I get an official word from UT on this?

I’d rather not rewrite all of my XML parsing if I can avoid it using XmlTextReader. Is this a bug, working as intended (i.e. broken for iPhone Basic), or what? I would upgrade to Pro if that would for sure make this problem go away, but I don’t want to upgrade and still have this problem?

Anyone else using XmlDocument successfully in iPhone Basic or Advanced for that matter?

As mentioned, with 1.5.1 it was disabled on purpose because it would die directly on linking as you pass the border of the allowed static library sizes without stripping if you include any system library thats not part of the corelib itself (like System.XML among others)

I would guess that you should still get a similar error message during on 1.6 if it is still not possible (which I would expect in case of 2.1), which is why I asked if you are sure on the content of the error message (clicking on it shows the full one)

I submitted a bug report. I’ll post the official resolution or official feedback I get from UT.

I love Unity, it is a fabulous tool, but I am fed up wasting my time guessing over and over about what is and what is NOT supported when Unity claims .net 1.1 or 2.1 support. If my problem is a Basic issue that is fine, but somewhere a definitive list of the portions of .net that are supported and not supported should be listed clearly so people aren’t wasting time guessing.

I don’t see where guessing is involved.
Build does allow it → supported
Build does not allow it → not supported

pretty simple binary logic

A list that contains basic informations on what does not work would though be nice (there never will be an ultimate complete list, as AoT is just AoT, there are things that work with one type of class and just will not work with others. thats the price of AoT that you will run up walls in these cases)

Thanks for the snide reply, but I generally don’t attempt a build for every include/using I add before I write code that uses them. Especially when the documents say should be supported… do you?..honestly? If so you have a very non-standard development style.

Edit: FYI System.Xml has been supported in .Net since version 1.0 in both standard and compact frameworks.

Edit2: And regardless of this. Unity throwing a Sockets exception is an entirely different issue.

Unity does not use MS .NET so your references to it are not directly related.
Also neither of the two are AoT enforced with static library size restrictions like the iPhone

None the less it has been supported since the first iphone version.
But on iPhone Basic, using System; and using System.Xml; was up to 1.5.1 at least disabled completely resulting in a build error informing you about that because the resulting mono library passes the allowed size by iphone sdk restrictions and you can no longer link the project at all.
These two namespaces only worked up to 1.5.1 only with iphone advanced and stripping.

I doubt that too much changed on that end with 1.6 especially if you choose .NET 2.1 where you lose the “smaller size” benefit directly again as .NET 2.1 is larger than .NET 1.1 was in 1.5.1 at all.

I’m saying these things because my assumption is that the error you see now with sockets in reality attempts to point towards this (always assuming that none of the frameworks you use has using System.Net in which is Advanced only)

http://www.mono-project.com/Compatibility

Mono doesn’t show any further back than 1.1, so it is anyone’s guess, but as you can see System.Xml has been supported since the 1.1 release.

I really appreciate your comments around the board on this and many other topics, and here, about the build sizes, exclusions and so forth, that all makes sense.

I just want an official UT response about the Mono .Net support , why I am getting a Sockets exception when not using Sockets.Net, and as soon as possible for official usable documentation to be made available for all Unity\Unity iPhone devs so stuff like this isn’t an issue moving forward. In any event, I will post the information I am provided to all interested parties.

Hi,
this is a bug. Hopefully it will be fixed with next Unity iPhone release.

I use xml and try to build on iPhone Basic and get the same error about .net sockets :?

Thanks for the response, but “what part” is a bug? The XML should work (in basic and pro) and its not? Or just that trying to use it throws a Sockets exception? Any more specifics you can provide?

It should not throw that Sockets usage exception in your case.

HAHA. You are definitely a man of few words.

So to be clear, System.Xml should work and be available as part of your advertised Mono .Net 1.1 and 2.1 support in Basic and Advanced? Or it should not work (like it doesn’t now) but just not throw the sockets exception?