【发布时间】:2017-04-20 21:30:37
【问题描述】:
.NET Standard 不支持“System.ComponentModel.DataAnnotations”和“System.Type.Properties”,如何保持兼容?
【问题讨论】:
.NET Standard 不支持“System.ComponentModel.DataAnnotations”和“System.Type.Properties”,如何保持兼容?
【问题讨论】:
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; 添加到您的源代码中。
【讨论】: