【问题标题】:ASPNET5 Class Library throws Current Runtime Target Framework is not compatible with '<ProjectName>'ASPNET5 类库抛出 Current Runtime Target Framework is not compatible with '<ProjectName>'
【发布时间】:2016-04-23 16:00:28
【问题描述】:

我想在一个单独的类库项目(名称为AbsenceRequests.Data.EF)中做 EntityFramework 工作,以便可以单独维护它。

我在 project.json 系统中遇到了一些问题,目前它看起来像这样:

{
  "version": "1.0.0-*",
  "description": "AbsenceRequests.Data.EF Class Library",
  "authors": [ "authorName" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "frameworks": {    
    "netcore50": {
      "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": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final"
  }
}

当我在命令行上运行dnx ef 时,我收到以下错误:

C:\...\AbsenceRequests\AbsenceRequests.Data.EF>dnx ef
System.InvalidOperationException: The current runtime target framework is not compatible with 'AbsenceRequests.Data.EF'.
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)'
 Version:      1.0.0-rc1-16202
 Type:         Clr
 Architecture: x86
 OS Name:      Windows
 OS Version:   6.1
 Runtime Id:   win7-x86

Please make sure the runtime matches a framework specified in project.json
   bij Microsoft.Dnx.ApplicationHost.DefaultHost.GetEntryPoint(String applicatio
nName)
   bij Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, Strin
g applicationName, String[] args)
   bij Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- Einde van stacktracering vanaf vorige locatie waar uitzondering is opgetrede
n ---
   bij System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bij Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly
, String[] args, IServiceProvider serviceProvider)
   bij Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment
 env, String appBase, FrameworkName targetFramework)
   bij Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, Bootst
rapperContext bootstrapperContext)
   bij Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, Bootstrappe
rContext bootstrapperContext)

当我使用常规的 Web 项目(甚至是从头开始)时,效果很好。但是对于类库项目,这会失败。有什么想法吗?我做错了什么?

谢谢 伊夫

【问题讨论】:

    标签: asp.net entity-framework dnx .net-core dnvm


    【解决方案1】:

    我自己也遇到过这个问题,我通过在 project.json 中添加以下内容来解决。

    "frameworks": {
        "dnx451": { },
        "dnxcore50": { }
      },
    

    当我最初创建类库项目并将其更改为 dnx451 时,它被设置为 net451。因此,请确保它知道该项目要使用哪些版本的框架。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-28
      • 1970-01-01
      • 1970-01-01
      • 2022-10-14
      • 2020-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多