0

使用 xsd 为 xml 文件生成 c# 代码时,出现错误:

命名空间“System”中不存在类型或命名空间名称“SerializableAttribute”(您是否缺少程序集引用?)

命名空间“System.ComponentModel”中不存在类型或命名空间名称“DesignerCategoryAttribute”(您是否缺少程序集引用?)

产生错误的代码:

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]

我试着寻找答案。我唯一发现的是:http: //support.microsoft.com/kb/916649

但这对我不起作用。解决方案资源管理器中没有系统文件夹!我正在使用 Visual Studio 2012,并且正在开发 ac#/xaml Metro 应用程序!

4

1 回答 1

0

Okay looks like xsd is not yet supported with metro applications! The following link explains that!

http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/88d9b73b-5faa-4204-9d06-dc121e709943/

the Perl script in the last answer can be used to remove the [System.SerializableAttribute()] and [System.ComponentModel.DesignerCategoryAttribute("code")] annotations if you have a big deep xml structure! I did not so I just removed them manually!

I am not sure if removing these annotations will have any bad side effects though. I will update this answer if I face any!

Thanks

于 2012-12-05T06:20:19.097 回答