我需要从网络核心中的 xsd 生成一个类。
在 dotnet 标准中,我使用了命令行 xsd filename.xsd /c.
但是如何在 net core 中创建这个类。
任何人都知道如何做到这一点?
当我添加一个用 xsd.exe 生成的类时,我收到了几个错误。
例子
Error CS0234 The type or namespace name 'SerializableAttributeAttribute' does not exist in the namespace 'System' (are you missing an assembly reference?)
Error CS0234 The type or namespace name 'DesignerCategoryAttribute' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?)
Error CS0234 The type or namespace name 'XmlTypeAttributeAttribute' does not exist in the namespace 'System.Xml.Serialization' (are you missing an assembly reference?)
Error CS0246 The type or namespace name 'AnonymousType' could not be found (are you missing a using directive or an assembly reference?)
autogen 文件中类的属性
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
最佳答案
我现在已经通过向我的项目添加 nugets 解决了这个问题。
解决方案:删除除 DesignerCategoryAttribute 之外的序列化属性问题
解决方案:删除 DesignerCategoryAttribute
现在可以编译 xsd.exe 生成的类并在 net core 中使用它
关于asp.net-core - 从net core中的xsd文件生成一个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43778093/