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

时间:2012-12-03 02:21:33

标签: c# xsd visual-studio-2012 microsoft-metro

使用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,我正在开发一个c#/ xaml metro app!

1 个答案:

答案 0 :(得分:0)

好的,看起来地铁应用程序还不支持xsd!以下链接解释了这一点!

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

如果你有一个很深的xml结构,最后一个答案中的Perl脚本可用于删除[System.SerializableAttribute()]和[System.ComponentModel.DesignerCategoryAttribute(“code”)]注释!我没有,所以我只是手动删除它们!

我不确定删除这些注释是否会产生任何不良副作用。如果我面对任何问题,我会更新这个答案!

由于