【问题标题】:How to replace the classes of System.ComponentModel.DataAnnotations for .NET Standard?如何替换 .NET Standard 的 System.ComponentModel.DataAnnotations 类?
【发布时间】:2017-04-20 21:30:37
【问题描述】:

.NET Standard 不支持“System.ComponentModel.DataAnnotations”和“System.Type.Properties”,如何保持兼容?

【问题讨论】:

    标签: .net-core .net-standard


    【解决方案1】:

    System.ComponentModel.DataAnnotations 命名空间中的类型在 the System.ComponentModel.Annotations package 中,默认情况下未安装在 .Net 标准库中,因此您需要手动安装它才能在那里使用它。

    如果您的意思是 Type.GetProperties(),那么该方法作为 .Net Core 和 .Net Standard 中的扩展方法存在。在 .Net 标准库中,您需要安装 the System.Reflection.TypeExtensions package。在 .Net Core 应用程序和 .Net 标准库中,您需要将 using System.Reflection; 添加到您的源代码中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-23
      • 1970-01-01
      • 1970-01-01
      • 2016-12-16
      相关资源
      最近更新 更多