【问题标题】:Unable to start ASP Application using `dnx run` on Ubuntu无法在 Ubuntu 上使用“dnx run”启动 ASP 应用程序
【发布时间】:2016-02-14 18:41:05
【问题描述】:

我使用的是 Ubuntu 14.04

我已经使用这些说明安装了 ASP http://docs.asp.net/en/latest/getting-started/installing-on-linux.html#installing-on-ubuntu-14-04

运行dnvm list 给了我以下信息:

Active Version              Runtime Architecture OperatingSystem Alias
------ -------              ------- ------------ --------------- -----
  *    1.0.0-rc1-update1    coreclr x64          linux           default
       1.0.0-rc1-update1    mono                 linux/osx      

然后我尝试使用本教程创建一个 ASP 应用程序: https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-app-using-vscode/

但是,当我运行 dnx run 时,我收到以下错误:

System.InvalidOperationException: IHostingBuilder.UseServer() is required for Start()
   at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureServer()
   at Microsoft.AspNet.Hosting.Internal.HostingEngine.BuildApplication()
   at Microsoft.AspNet.Hosting.Internal.HostingEngine.Start()
   at Microsoft.AspNet.Hosting.WebApplication.Run(Type startupType, String[] args)
   at ASPTutorial.Startup.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.ApplicationHost.Program.<>c__DisplayClass3_0.<ExecuteMain>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

当我从 coreclr 更改为 mono 时,会出现类似的问题。

更新

dnx web 工作正常!

【问题讨论】:

  • dnx web 怎么样?
  • 行得通!为什么dnx run 不起作用???
  • dnx run 通常用于运行控制台应用程序。
  • dnx run 用于控制台应用程序。顺便说一句:你可能想看看使用dotnet cli,因为dnx 正在退休;-) github.com/dotnet/cli
  • 我很困惑为什么教程说要使用dnx rundotnet cli 也是微软官方维护的还是社区的东西?

标签: asp.net ubuntu mono dnx coreclr


【解决方案1】:

使用 dnx 运行的命令在项目的 project.json 中定义。

如 cmets 中所述,“run”通常用于控制台应用程序,“web”用于 Web 应用程序。但是你可以在你的 project.jseon 中写任何你想要的命令名,甚至是这样的:

"commands": {
    "runmyawesomeapp": "[...]"
}

你可以用

运行它
> dnx runmyawesomeapp

希望这会有所帮助:)

【讨论】:

  • 我明白了。但是我很惊讶为什么教程要求dnx run,而没有run 命令。
  • 因为是微软
猜你喜欢
  • 2014-10-28
  • 1970-01-01
  • 1970-01-01
  • 2017-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-04
相关资源
最近更新 更多