1

I am trying to use XmlDocument in a C# application on MacOS in Visual Studio Code. However, when I try to use the class name, the editor reports the following error:

The type or namespace 'XmlDocument' could not be found

My application correctly references System.Xml:

using System;
using System.Xml;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            XmlDocument doc;
            Console.WriteLine();
            Console.ReadLine();
        }
    }
}

The only thing that I can think of is that my application's configuration is restricting the APIs that I can access (based off this response).

Here is the project.json:

{
    "version": "1.0.0-*",
    "buildOptions": {
      "debugType": "portable",
      "emitEntryPoint": true
    },
    "dependencies": {},
    "frameworks": {
      "netcoreapp1.0": {
        "dependencies": {
          "Microsoft.NETCore.App": {
            "type": "platform",
            "version": "1.0.0"
          }
        },
        "imports": "dnxcore50"
      }
    }
  }

Is the System.Xml namespace simply severely restricted on .NET Core, or have I mis-configured my application?

Editing for Solution

The reason that I didn't have most of the packages is that projects default to .NET Core. If you want access to the .NET Standard libraries, you need to include the package in your project. Instructions for doing this using nuget are here

kop48
  • 505
  • 3
  • 8
  • In the question you referenced, the correct assembly was not referenced. Are you sure you are referencing the correct assembly? – CodingYoshi Dec 05 '16 at 04:10
  • @CodingYoshi - unfortunately, I haven't been able to find any documentation for VS Code and .NET Core on how to reference assemblies. I can see an example here, but I'm not sure what version number I should be using if I include 'System.Xml' to my references: http://stackoverflow.com/questions/31888274/how-to-reference-assemblies-using-visual-studio-code – kop48 Dec 06 '16 at 05:52

0 Answers0