Search code examples
c#dnx.net-4.6coreclrdnvm

System.InvalidOperationException: The current runtime target framework is not compatible with 'HelloWorld'


I am trying to run a first helloword app with .net 5 and visual studio code.

If I enter dnvm list I have this:

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

And my project.json is simple:

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

But when I run the app with DNX RUN on the folder I get this error

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>

Solution

  • When I run the program with dnx run on a new console command it doenst work. However when I run the program with dnx run on the vs 2015 command prompt where I used the dnvm use command it works perfectly fine.

    It looks to me that the dnvm use with the -p persistent parameter is not working properly because in the second command prompt it tries to use the coreclr even when the default and active framework is clr only.

    and to answer Yeoman, the project.json is totally fine, I didnt modify anything to run