XmlWriter 类型中不存在类型名称 'Create'
The type name 'Create' doesn't exist in the type XmlWriter
我正在尝试在 Visual Studio 2017 上编写一个 Xml 程序,但出现错误:
using System.Xml;
...
XmlWriter.Create("C:\myxmlfile.xml", settings);
加上这条消息:The type name 'Create' doesn't exist in the type XmlWriter.
我怀疑我的 Visual Studio 安装不完整(不幸的是还没有修复)导致了这个问题。我该如何解决?
我猜你的代码实际上是这样的:
var writer = new XmlWriter.Create("C:\myxmlfile.xml", settings);
如果是,则删除 new
即可。
原因是在XmlWriter中classCreate是static的所以不能new.
在我的案例中,是由于与另一个库发生冲突。
我必须像这样指定它:
System.Xml.XmlWriter.Create(sww)
希望它对你也有用。
我正在尝试在 Visual Studio 2017 上编写一个 Xml 程序,但出现错误:
using System.Xml;
...
XmlWriter.Create("C:\myxmlfile.xml", settings);
加上这条消息:The type name 'Create' doesn't exist in the type XmlWriter.
我怀疑我的 Visual Studio 安装不完整(不幸的是还没有修复)导致了这个问题。我该如何解决?
我猜你的代码实际上是这样的:
var writer = new XmlWriter.Create("C:\myxmlfile.xml", settings);
如果是,则删除 new
即可。
原因是在XmlWriter中classCreate是static的所以不能new.
在我的案例中,是由于与另一个库发生冲突。 我必须像这样指定它:
System.Xml.XmlWriter.Create(sww)
希望它对你也有用。