Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can't find System.Linq.Xml

Discussion in 'Editor & General Support' started by johot, Apr 20, 2011.

  1. johot

    johot

    Joined:
    Apr 11, 2011
    Posts:
    201
    I've googled this, searched the Unity forum and so on but can't find a good answer.

    Created an editor wizard script today that uses System.Xml.Linq. Now Unity says this assembly reference can not be found.

    I've read about people using it, old forum posts says this is not possible since Unity uses an old version of .NET but those posts where from 2 years ago.

    Is it possible to get it working? How can I add an assembly reference from the Unity editor, I have tried using a visual studio project, adding it there and so on but Unity doesn't pick this up.

    Same error in both Unity free and pro...
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Have you checked that the Mono API compatibility setting is set to 2.0 rather than 2.0 Subset? (Menu: Edit > Project Settings > Player and then look in the Other Settings panel in the inspector.) Unity doesn't implement the whole Mono API anyway but it implements an even more limited subset of the API by default in the interests of saving memory.
     
  3. Razieln64

    Razieln64

    Joined:
    May 3, 2008
    Posts:
    129
    I have the same problem. System.Xml.Linq is part of .net 3.5 so maybe that's why it doesn't work. I'd like to use it only for editor scripts as it makes life easier when saving information to XML.
     
  4. Barry Holroyd

    Barry Holroyd

    Joined:
    Mar 21, 2009
    Posts:
    17
    Wow. I was receiving this error when trying to use Link2Sql:

    Internal compiler error. See the console log for more information. output was:
    Unhandled Exception: System.TypeLoadException: Could not load type 'AmksDb.AmksDbMain' from assembly 'AmksDb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

    I spent several hours trying to figure out the problem. In the end, it couldn't find System.Data.Linq and the cause was that my Mono API compatibility setting was set to 2.0 Subset. I didn't know about that setting (pretty obscure place for it, although I imagine there's a reason) until Andeeee's message above. I set it to 2.0 and now everything works.

    THANK YOU ANDEEEE!
    Barry
     
  5. badbod99

    badbod99

    Joined:
    May 3, 2011
    Posts:
    36
    It still doesn't work on Unity4 with ".Net 2.0" selected in Api Compatibility. I can added the reference to System.Xml.Linq in MonoDevelop, but when I switch to Unity I get this:

    Code (csharp):
    1. The type or namespace name `Linq' does not exist in the namespace `System.Xml'. Are you missing an assembly reference?
    So it looks link Unity (even in version 4) does not support this part of Mono.
     
  6. frost86

    frost86

    Joined:
    Dec 4, 2012
    Posts:
    1
    Copy System.Xml.Linq.dll from ..\unity\editor\data\mono\lib\mono\unity\ folder to your projet' Asset\Plugins. This will solve your problem.
     
  7. luizcarlosfx

    luizcarlosfx

    Joined:
    May 28, 2013
    Posts:
    15
    How do you get this working? I also tried it and this didn't work for me! Which version of System.Data.dll are you using?
     
  8. OskarSwierad

    OskarSwierad

    Joined:
    Dec 17, 2014
    Posts:
    25
    Sorry for excavating the thread, but I want to share a solution that worked for me. It seems I had the project set to a wrong platform (Web instead of PC) and was missing PC platform files.

    - open File > Build Settings
    - if the selected platform is Web, that's the problem
    - select PC, Mac & Linux Standalone
    - for me, the Switch Platform button was greyed out. On the right, there was a button to "Open Download Page"
    - I got the missing files' installer
    - After that, Switch Platform button was unlocked
    - I clicked it, waited for the process to end, restarted the editor

    The System.Xml.Linq problem is gone :)