【问题标题】:Unable to run dnx console App无法运行 dnx 控制台应用程序
【发布时间】:2015-09-01 08:07:30
【问题描述】:

我已经按照link 运行了一个 dnx 控制台应用程序。我创建了两个文件 Program.cs 和 project.json,其内容如链接中所述

这是我执行的命令序列

    F:\first-dnx> dnvm list

    Active Version           Runtime Architecture OperatingSystem Alias
    ------ -------           ------- ------------ --------------- -----
           1.0.0-beta6       clr     x86          win
           1.0.0-beta6       coreclr x64          win
      *    1.0.0-beta8-15530 clr     x86          win             default

F:\first-dnx> dnu restore
Microsoft .NET Development Utility CLR-x86-1.0.0-beta8-15530

Restoring packages for F:\first-dnx\project.json
  CACHE https://www.myget.org/F/aspnetvnext/api/v2/
  CACHE https://www.nuget.org/api/v2/
Writing lock file F:\first-dnx\project.lock.json
Restore complete, 490ms elapsed

NuGet Config files used:
    C:\Users\sam\AppData\Roaming\NuGet\NuGet.Config

Feeds used:
    https://www.myget.org/F/aspnetvnext/api/v2/
    https://www.nuget.org/api/v2/
F:\first-dnx> dnu build

项目已成功构建,但当我尝试运行应用程序时 抛出以下异常

F:\first-dnx> dnx . run
System.InvalidOperationException: Unable to load application or execute command '.'. Available commands: ConsoleApp1.
   at Microsoft.Dnx.ApplicationHost.Program.ThrowEntryPointNotfoundException(DefaultHost host, String applicationName, Exception innerException)
   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, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
F:\first-dnx> dnx . ConsoleApp1
System.InvalidOperationException: Unable to load application or execute command '.'. Available commands: ConsoleApp1.
   at Microsoft.Dnx.ApplicationHost.Program.ThrowEntryPointNotfoundException(DefaultHost host, String applicationName, Exception innerException)
   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, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
F:\first-dnx>

【问题讨论】:

    标签: asp.net-core dnx dnvm dnu


    【解决方案1】:

    您不必再添加. 来指定基本路径。试试:

    dnx run
    

    这在 beta7 中有所改变。请参阅:https://github.com/aspnet/Announcements/issues/52

    【讨论】:

    • dnx run 是执行当前项目入口点的简写。它应该以 ConsoleApp1 开头。
    • dnx 命令(这里是 project.json 中的 consoleApp1)也应该运行应用程序,rt?
    • 但是正在抛出与上面提到的相同的错误,知道吗?
    • dnx ConsoleApp1 输出什么?
    • 现在我明白了,我应该将命令的名称指向文件夹的名称。更改后,“commands”:{“ConsoleApp1”:“first-dnx”}就可以了。谢谢!!!
    猜你喜欢
    • 1970-01-01
    • 2020-11-19
    • 2016-01-26
    • 1970-01-01
    • 2011-01-22
    • 1970-01-01
    • 1970-01-01
    • 2012-05-28
    • 1970-01-01
    相关资源
    最近更新 更多