Search code examples
xmlvisual-studio-2017xmlwriter

The type name 'Create' doesn't exist in the type XmlWriter


I'm trying to write an Xml program on Visual Studio 2017 and have error on:

using System.Xml;
...
XmlWriter.Create("C:\\myxmlfile.xml", settings);

With this message: The type name 'Create' doesn't exist in the type XmlWriter.

I suspect that incomplete installation (which unfortunately didn't fixed yet) of my Visual Studio caused this problem. How can I fix it?


Solution

  • My guess is that your code actually looks something like this:

    var writer = new XmlWriter.Create("C:\\myxmlfile.xml", settings);
    

    if it is then remove the new and it will work. The reason is that in the XmlWriter class Create is static so can not be newed.