【问题标题】:XmlReader behaves correctly on Win 8, fails on Win 2008XmlReader 在 Win 8 上正常运行,在 Win 2008 上失败
【发布时间】:2014-02-07 03:43:07
【问题描述】:

通过 XmlReader 验证 XML 文件我正确得到以下错误:

元素“Contact”具有无效的子元素“ContactEmail”。预期的可能元素列表:“ContactPhone”。

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ValidationType = ValidationType.Schema;
            settings.Schemas = sc;
            settings.ValidationEventHandler += vh;
            settings.IgnoreComments = true;
            settings.IgnoreWhitespace = true;

            XmlReader reader = XmlReader.Create(xmlPath, settings);

            // loop follows

糟糕的 XML 看起来像这样

        <Contact>
            <ContactName/>
            <ContactEmail/>
        </Contact>

应该是这样的

        <Contact>
            <ContactName/>
            <ContactPhone/>
            <ContactEmail/>
        </Contact>

到目前为止一切顺利。

将代码、架构和 XML 文件从 Windows 8 移动到我们的 2008 服务器,XML 错误被忽略,文件被验证为良好。

在目标服务器上编译,没有变化。 将构建类型设置为 64,没有变化。

我还应该寻找什么?

谢谢!

【问题讨论】:

  • 什么版本的2008服务器?
  • Windows Server 2008 R2 SP1
  • 已解决 将目标框架从 3.5 降到 3.0,并且代码在两种环境中都可以工作。
  • 这很有趣。

标签: c# xml xmlreader


【解决方案1】:

已解决

将目标框架从 3.5 降到 3.0,并且代码在两种环境中都可以工作。 (我仍然很想听听有人告诉我为什么它在 3.5 不一致地失败)

【讨论】:

    猜你喜欢
    • 2013-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多