asp.net-core - 无法运行 dnx 控制台应用程序

标签 asp.net-core dnx dnvm dnu

我已关注此 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>

最佳答案

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

dnx run

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

关于asp.net-core - 无法运行 dnx 控制台应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32326586/

相关文章:

asp.net-core - ASP.NET 5、DNX 和红隼 : Not hitting breakpoints

c# - 更新到 ASP NET 5 beta5 会破坏一切

c# - 升级到 ASP.NET MVC6 beta 7 后打开现有项目时出现异常

c# - 将子类转换到父类。我做得对吗?

c# - IServiceCollection 不包含定义 AddJsEngineSwitcher

asp.net - 将 ASP.NET 4 Razor "extensionless URLs"站点移植到 ASP.NET 5

.net - DNX 1.0.0-RC1-Update2 中有什么

visual-studio-2015 - 添加的新 Bower 包在关闭/打开之前不会显示在解决方案中

asp.net - 如何使用ASP.NET 5调用RESTful API

asp.net-mvc - ASP.NET OmniSharp 服务器未在 Ubuntu Mono 上运行