Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在.NET core的完整/核心平台中启用DataAnnotation_C#_Asp.net Core_.net Core - Fatal编程技术网

C# 在.NET core的完整/核心平台中启用DataAnnotation

C# 在.NET core的完整/核心平台中启用DataAnnotation,c#,asp.net-core,.net-core,C#,Asp.net Core,.net Core,我创建了一个.NET核心(包)库项目,它有一个类,如下所示: public class Subscriber //: Representation { [Required] public SubscriberDef Info; public Guid ProviderID; } "frameworks": { "net451": { "dependencies": { "WebApi.Hal": "2.6.0", } }, "do

我创建了一个.NET核心(包)库项目,它有一个类,如下所示:

public class Subscriber //: Representation
{
    [Required]
    public SubscriberDef Info;
    public Guid ProviderID;
}
"frameworks": {
  "net451": {
    "dependencies": {
      "WebApi.Hal": "2.6.0",
    }
  },
  "dotnet5.4": {
    "dependencies": {
      "Microsoft.CSharp": "4.0.1-beta-23516",
      "System.Collections": "4.0.11-beta-23516",
      "System.Linq": "4.0.1-beta-23516",
      "System.Runtime": "4.0.21-beta-23516",
      "System.Threading": "4.0.11-beta-23516",
    }
  }
},
"dependencies": {
  "Excqape": "0.7.0",
  "System.ComponentModel.Annotations": "4.0.11-beta-23516"
}
无论我做什么,编译器都不满意
[Required]
属性。我经常被告知:

NET Framework 4.5.1 - Not Available
NET Platform 5.4 - Available
我的project.json最初是这样的:

public class Subscriber //: Representation
{
    [Required]
    public SubscriberDef Info;
    public Guid ProviderID;
}
"frameworks": {
  "net451": {
    "dependencies": {
      "WebApi.Hal": "2.6.0",
    }
  },
  "dotnet5.4": {
    "dependencies": {
      "Microsoft.CSharp": "4.0.1-beta-23516",
      "System.Collections": "4.0.11-beta-23516",
      "System.Linq": "4.0.1-beta-23516",
      "System.Runtime": "4.0.21-beta-23516",
      "System.Threading": "4.0.11-beta-23516",
    }
  }
},
"dependencies": {
  "Excqape": "0.7.0",
  "System.ComponentModel.Annotations": "4.0.11-beta-23516"
}
我尝试将目标框架名字对象(TFM)从
net451
切换到
net46
。不走运。我尝试了两个框架使用的System.ComponentModel.Annotations的不同版本,但仍然没有成功

特别奇怪的是,如果我创建了一个ASP.NET核心项目,那么我就可以自由地拥有两个框架,其中数据注释受到尊重并将编译:

"frameworks": {
  "dnx46": { },
  "dnxcore50": { }
},
我想如果数据注释在ASP.NET内核中工作,那么它们肯定也能在.NET内核中工作

我是否做错了什么,或者目前.NET Core fullCLR确实无法使用数据批注?


这是一个新平台,请先了解如何搜索所需的NuGet软件包。

PackageSearch-这是一个非常有用的网站,我现在知道了,谢谢!