.NET Standard 不支持“System.ComponentModel.DataAnnotations”和“System.Type.Properties”,如何保持兼容?
最佳答案
来自 System.ComponentModel.DataAnnotations
的类型命名空间位于 the System.ComponentModel.Annotations
package ,默认情况下不会安装在 .Net Standard 库中,因此您需要手动安装它才能在那里使用它。
如果您的意思是 Type.GetProperties()
,那么该方法作为 .Net Core 和 .Net Standard 中的扩展方法存在。在 .Net Standard 库中,您需要安装 the System.Reflection.TypeExtensions
package .在 .Net Core 应用程序和 .Net Standard 库中,您都需要添加 using System.Reflection;
到您的来源。
关于.net-core - 如何替换 .NET Standard 的 System.ComponentModel.DataAnnotations 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43508648/