Hi, I'm trying to use the System.Xml.Linq namespace to do some xml generation/parsing. Is there any way to get this to work?
I get these weird messages in Unity when I try to use XElement. The following code gives error messages:
This code works:
The error message I get is:
I guess it's not implemented in the version of Mono used by Unity and thus not available. A suggestion I read elsewhere was to use a C++ plugin that calls into a .Net assembly. This will allow the .Net assembly to use the Microsoft GAC instead of the Mono GAC.
answered May 26, 2011 at 08:20 AM
I had to work around this error by removing all use of XElement. Basicly I stopped using System.Xml.Linq and recoded my serializer to make use of System.Xml exclusively. Unfortunately this is just a poor work around rather than a proper fix.
answered Feb 09, 2011 at 05:17 PM
Based on the code snippets I see either you are using C# and using its var command (which would work for certain things, but it shouldn't be used here) or you are using another language all together.
Anyways if this is indeed C# change your var to XDocument. var should only be used when you don't know for sure what type of variable is going to be sent to a function or class. If you are using var throughout your code you are slowing down your code and increasing the time it takes to compile your code along with bringing possible unnecessary bugs to your game.
If what I said is indeed what you are doing I would recommend reading up on C# and learning proper syntax for C#. All of your variables should either use int, float, double, bool, char, string, enum, or the name of a class. var should only be used when absolutely necessary.
I hope this helps with your problem.
answered Apr 07, 2011 at 08:15 PM