none
System.Xml.XmlDocument does not exist

    Question

  • I'm getting this strange error. It popped up randomly after I loaded my project one time (no changes were made, project has compiled successfully before).

    "Error    CS0246    The type or namespace name 'XmlDocument' could not be found (are you missing a using directive or an assembly reference?) "

    I of course have "using System.Xml;" and according to the MSDN references, XmlDocument is most certainly a part of the Windows UWP version I'm using.

    Here is a picture of my references (IoT extensions are the same version number):

    I have tried completely removing UWP by uninstalling and reinstalling via nuget. No luck.

    This is the line of code that errors out:

    XmlDocument doc = new XmlDocument();

    Something else I noticed that was strange is that System.Xml (along with a few other namespaces) would not expand in the object browser. The various System.Threading namespaces seemed to have normal functionality. I've tried running as administrator and disabling antivirus to make sure there are no file permission or other sorts of errors, but still no luck.

    I have no idea how to fix this


    Here are some links to files that might help I guess:

    project.lock.json: https://www.dropbox.com/s/q4wx99ht81odewy/project.lock.json?dl=1

    .csproj:https://www.dropbox.com/s/jmu721s7rf4nu67/MirrorInterface.csproj?dl=1

    • Edited by Goigle Sunday, December 18, 2016 3:42 PM adding files
    • Moved by IoTGirl Sunday, December 18, 2016 8:16 PM Not IoT Specific
    Sunday, December 18, 2016 3:32 PM

Answers

  • OK, so before I scratched the project I decided to look at the git changes and see what the heck happened to the project.

    In project.json, nuget changed the following:

    "dependencies": {
        "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0"
      },

    to:

    "dependencies": {},

    Everything is well now.

    • Marked as answer by Goigle Sunday, December 18, 2016 10:17 PM
    Sunday, December 18, 2016 10:17 PM

All replies

  • Hi Goigle,

    This should work the same as other flavors of Windows 10. https://social.msdn.microsoft.com/Forums/en-US/2323e6c8-cabb-42fb-beec-c9e58ae58549/reading-and-writing-and-xml-file-on-windows-iot-core?forum=WindowsIoT.  Have you reviewed this error in other forums?

    There are quite a few reasons an assembly may not be available.  Did you change any other settings in your project that may have impacted this? See http://stackoverflow.com/questions/4764978/the-type-or-namespace-name-could-not-be-found for example but there are likely other interactions within VS that could cause this issue.

    Sincerely,

    IoTGirl


    • Edited by IoTGirl Sunday, December 18, 2016 6:12 PM
    Sunday, December 18, 2016 6:07 PM
  • The project was previously compiling for x86, x64, and ARM perfectly fine. I'm thinking it's a VS issue. I have not checked for help elsewhere, I meant to post in the UWP forum but I hadn't had my coffee yet so I posted here.

    The second link is similar to my problem. The using statement in my project is fine, however the specific class (and some related classes) are not showing up in the namespace. The namespace itself does show up. I'm targeting a version of Windows that should definitely have the System.Xml dll.

    As far as I know, no settings have been altered. Finals got in the way and I didn't touch the project, however when I left it it was in a working state.

    Edit:
    I just checked, and I was on 10586 so I tried upping the version to Win 10 Anniversary (10.0.14393.0) but the project still won't build.
    According to: https://msdn.microsoft.com/en-us/library/system.xml.xmldocument%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

    I should be targeting a version that it works on.

    Could this be the problem? Visual studio says the path to Univeral Windows is:

    C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Calls.CallsVoipContract\1.0.0.0\

    It also looks like my System.Xml.dll is coming from here:

    C:\Users\sevru\.nuget\packages\Microsoft.NETCore.Portable.Compatibility\1.0.2\ref\netcore50\System.Xml.dll

    That file is only 22 kb. I looked at it in Jetbrains DotPeek to make sure all the classes were there, and nothing showed up.

    • Edited by Goigle Sunday, December 18, 2016 7:17 PM
    Sunday, December 18, 2016 7:00 PM
  • I think something happened with my project or solution and nuget, I'm going to start a new project and import my code and see if it works.
    Sunday, December 18, 2016 8:23 PM
  • Hi Goigle,

    I have moved your question to the VS forums in hopes that they are more familiar with what might be going on with your project.

    Sincerely,

    IoTGirl

    Sunday, December 18, 2016 9:34 PM
  • Thanks!
    Sunday, December 18, 2016 10:12 PM
  • OK, so before I scratched the project I decided to look at the git changes and see what the heck happened to the project.

    In project.json, nuget changed the following:

    "dependencies": {
        "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0"
      },

    to:

    "dependencies": {},

    Everything is well now.

    • Marked as answer by Goigle Sunday, December 18, 2016 10:17 PM
    Sunday, December 18, 2016 10:17 PM
  • Excellent!
    Sunday, December 18, 2016 10:42 PM