XmlDocument 存在于哪个程序集中,以及如何使用它?

发布于 2024-10-10 18:02:11 字数 585 浏览 0 评论 0 原文

我有以下代码:

using System.Xml;
namespace MyApp {
  public class Foo : IBar {
    public void SomeCallback(object sender, CallbackEventArgs e) {
      string s = e.Result;
      System.Xml.XmlDocument xml;  // <-- Error CS0234.
      ...

这会导致错误CS0234:命名空间“System.Xml”中不存在类型或命名空间名称“XmlDocument”(您是否缺少程序集引用?)

我已验证System.Xml 包含在解决方案资源管理器的“引用”下。它被列为使用 2.0.xx,但这应该没问题,因为类 据称存在 那么?

我不太熟悉 .net 开发,所以我不知道如何解决这个问题。

I have the following code:

using System.Xml;
namespace MyApp {
  public class Foo : IBar {
    public void SomeCallback(object sender, CallbackEventArgs e) {
      string s = e.Result;
      System.Xml.XmlDocument xml;  // <-- Error CS0234.
      ...

This results in error CS0234: The type or namespace name 'XmlDocument' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?)

I have verified that System.Xml is included under "References" in Solution Explorer. It's listed as using 2.0.x.x, but that should be fine since the class allegedly existed then?

I'm not well versed in .net development, so I'm not sure how to troubleshoot this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉鱼一梦 2024-10-17 18:02:11

根据您对问题发布的评论,您似乎正在构建 Silverlight 应用程序。类型 XmlDocument 不包含在 Silverlight 版本的框架中。推荐的替代方案是 XDocument

这是有关在 Silverlight 应用程序中使用 XML 的教程页面

Based on the comment you posted to your question it looks like you are building a Silverlight application. The type XmlDocument is not included in the Silverlight version of the framework. The recommended alternative is XDocument

Here is a tutorial page on using XML in a Silverlight application

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文