0

我正在尝试使用 .net 5 和 Visual Studio 代码运行第一个 helloword 应用程序。

如果我输入 dnvm list 我有这个:

Active Version           Runtime Architecture OperatingSystem Alias
------ -------           ------- ------------ --------------- -----
       1.0.0-beta4       clr     x64          win
       1.0.0-beta4       clr     x86          win
       1.0.0-beta4       coreclr x64          win
       1.0.0-beta4       coreclr x86          win
       1.0.0-beta4-11566 clr     x64          win
       1.0.0-beta4-11566 clr     x86          win
       1.0.0-beta4-11566 coreclr x64          win
       1.0.0-beta5       clr     x86          win
       1.0.0-beta5       coreclr x86          win
  *    1.0.0-rc1-update1 clr     x64          win             default
       1.0.0-rc1-update1 clr     x86          win
       1.0.0-rc1-update1 coreclr x64          win
       1.0.0-rc1-update1 coreclr x86          win

我的 project.json 很简单:

{
    "frameworks": {
        "dnx451":{}
    }
}

但是当我在文件夹上使用 DNX RUN 运行应用程序时,出现此错误

System.InvalidOperationException: The current runtime target framework is not compatible with 'HelloWorld'.
Current runtime target framework: 'DNXCore,Version=v5.0 (dnxcore50)'
 Version:      1.0.0-rc1-16231
 Type:         CoreClr
 Architecture: x64
 OS Name:      Windows
 OS Version:   10.0
 Runtime Id:   win10-x64

Please make sure the runtime matches a framework specified in project.json
   at Microsoft.Dnx.ApplicationHost.DefaultHost.GetEntryPoint(String applicationName)
   at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
   at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, BootstrapperContext bootstrapperContext)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, BootstrapperContext bootstrapperContext)

d:\P\HelloWorld>
4

1 回答 1

0

当我在新的控制台命令上使用 dnx run 运行程序时,它确实有效。但是,当我在 vs 2015 命令提示符下使用 dnx run 运行程序时,我使用了 dnvm use 命令,它工作得非常好。

在我看来,与 -p 持久参数一起使用的 dnvm 无法正常工作,因为在第二个命令提示符下,即使默认和活动框架仅为 clr,它也会尝试使用 coreclr。

并回答 Yeoman,project.json 完全没问题,我没有修改任何东西来运行

于 2016-01-10T18:36:40.507 回答