【问题标题】:DNX (ASP.NET Core RC1) web application - cannot host in IISDNX (ASP.NET Core RC1) Web 应用程序 - 无法在 IIS 中托管
【发布时间】:2016-05-26 20:06:36
【问题描述】:

我正在尝试将仍在 ASP.NET RC1 (DNX) 上的 Web 应用程序部署到 IIS。我浏览了所有 Microsoft 文档,但我遇到了一个问题。应用程序启动时出现此错误:

Application startup exception: System.IO.FileLoadException: Could not load file or assembly 'Web' or one of its dependencies. General Exception (Exception from HRESULT: 0x80131500)
File name: 'Web' ---> Microsoft.Dnx.Compilation.CSharp.RoslynCompilationException: Startup.cs(104,39): DNX,Version=v4.5.1 error CS0012: The type 'Func<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

这是什么意思?我能够在我进行开发的本地机器上部署到 IIS,没有任何问题。但是,只有带有 IIS 的服务器不起作用。

我该如何解决这个错误?服务器在 Windows Server 2008 R2 上,我的本地机器是 Windows 7,如果有帮助的话。

【问题讨论】:

  • 您的服务器上是否安装了 DNVM 和正确的 dnx 运行时?
  • @Tseng 我不相信我会这样做,我怎样才能确定?不过我确实有 dnx 运行时。

标签: iis asp.net-core dnx


【解决方案1】:

我能够使用解决方法解决此问题。看起来这是 Visual Studio 2015 的 Publish 命令的问题。看起来它没有发布到 Nuget 包的选项。这意味着发布命令输出源文件。因此,这些文件仍然需要由服务器编译。

我没有找到如何让服务器正确编译文件。但是,我可以通过预先将代码编译到 Nuget 包中来解决它。这可以通过使用 dnu 命令行工具来完成。

dnu publish --out %folder% --no-source --include-symbols --runtime dnx-clr-win-x86.1.0.0-rc1-update1 --configuration Release

重要的部分是--no-source选项,它将打包成Nuget包。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多