繁体   English   中英

无法从 .Net Core 2.2 类生成 XSD 文件

[英]Cannot Generate XSD file from .Net Core 2.2 Class

我正在尝试将 .NET Core (2.2) 类转换为 xsd 文件。 课程很简单

[GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[SerializableAttribute()]
public class Core_Class
{
    public int ID { get; set; }
}

每次我尝试运行 xsd.exe 以在 .net 核心类上为我的类创建一个 xsd 文件时,我都会收到以下错误

Error: There was an error processing 'C:\Users\....\repos\.....\.....\bin\Debug\netcoreapp2.2\.....dll'.
  - Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

如果我在标准 .net 框架 4.6 项目中使用 xsd.exe 运行相同的命令,则会正确生成 xsd 文件。 有什么办法可以从 .net 核心类生成 xsd 文件?

在四处搜索并没有找到这个问题的答案后,我最终找到了一种解决方法而不是解决方案。 我不得不将我的 .NET 核心库转换为 .NET Standard 2.0 类库。 转换为 .NET 标准库允许 .NET 核心和 .NET 框架 (4.6+) 引用它们。 在此之后 xsd.exe 按预期工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM