ManagedRuntimeError System.NotSupportedException:XLinq。 使用 Visual Web Developer 使用 C# 开发 Silverlight

发布于 2024-07-23 18:34:24 字数 911 浏览 1 评论 0原文

我正在使用 Visual Web Developer 构建 Silverlight 类库。 我有另一个项目,其中导入并实现了类库。 它正在加载一个 XML 文件,并且我正在使用 XmlSerializer.Deserialize 到我用 xsd.exe 创建的类中。

有时,在加载 XML 时,我会收到此错误:

Unhandled Error in Silverlight 2 Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.InvalidOperationException: There is an error in XML document (149, 10). ---> System.NotSupportedException: XLinq
   at System.Xml.Serialization.XmlSerializationReader.ReadXmlNodes(Boolean elementCanBeType)
   at System.Xml.Serialization.XmlSerializationReader.ReadTypedPrimitive(XmlQualifiedName type, Boolean elementCanBeType)
   at System.Xml.Serialization.XmlSerializationReader.ReadTypedPrimitive(XmlQualifiedName type)

我发现仅当 XML 文件中存在名为 Extensions 的标记时才会出现此错误。 起初我认为这在 xsd.exe 生成的 C# 类中定义不正确,但如果我将 Extensions 更改为任何其他名称,它就可以工作。 不幸的是,简单地永久更改此标签的名称并不是一种选择。 我已经排除了保留字。 Google 没有有关此错误的信息。

I'm using Visual Web Developer to build a Silverlight Class Library. I have another project where the Class Library is imported and implemented. It's loading an XML file and I'm using XmlSerializer.Deserialize into a class I created with xsd.exe.

Sometimes, when loading the XML, I get this error:

Unhandled Error in Silverlight 2 Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.InvalidOperationException: There is an error in XML document (149, 10). ---> System.NotSupportedException: XLinq
   at System.Xml.Serialization.XmlSerializationReader.ReadXmlNodes(Boolean elementCanBeType)
   at System.Xml.Serialization.XmlSerializationReader.ReadTypedPrimitive(XmlQualifiedName type, Boolean elementCanBeType)
   at System.Xml.Serialization.XmlSerializationReader.ReadTypedPrimitive(XmlQualifiedName type)

I've discovered that it only occurs when there is a tag called Extensions in my XML file. At first I thought this was improperly defined in the C# class generated by xsd.exe, but it works if I change Extensions to any other name. Unfortunately, simply changing the name of this tag permanently is not an option. I've ruled out reserved words. Google has no info on this error.

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

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

发布评论

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

评论(1

青衫儰鉨ミ守葔 2024-07-30 18:34:25

这很奇怪。 您提供的堆栈跟踪似乎是不可能的。 如果您检查 System.Xml.dll 的 2.0 Silverlight 版本,您会注意到没有名为 XmlSerializationReader 的类。 此类仅存在于 System.Xml.dll 的完整框架版本中。

您是否尝试部署 System.Xml.dll 的框架版本? 或者您是否使用了我缺少的其他库来访问该类?

That's pretty weird. The stack trace you put up appears to be impossible. If you examine the 2.0 Silverlight version of System.Xml.dll, you'll notice that there is no class called XmlSerializationReader. This class is only present in the full framework version of System.Xml.dll.

Did you attempt to deploy the framework version of System.Xml.dll? Or are you using a different library that I'm missing to get access to that class?

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