簡體   English   中英

針對完整dotnet框架的ASP.NET Core Web應用程序是否可以在IIS中運行?

[英]Does ASP.NET Core web application targeting full dotnet framework work in IIS?

我試圖將完整框架(4.6.1)上開發的ASP.NET Core應用程序發布到IIS。 現在代碼只是使用Visual Studio“ASP.NET Core(.NET Framework)選項創建的基本模板代碼。代碼編譯得很好但是當我將它發布到本地IIS時,它無法啟動。我得到的錯誤就像

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.Extensions.PlatformAbstractions.PlatformServices' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Reflection.TypeExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.Extensions.PlatformAbstractions.ApplicationEnvironment.GetEntryAssembly()
   at Microsoft.Extensions.PlatformAbstractions.ApplicationEnvironment..ctor()
   at Microsoft.Extensions.PlatformAbstractions.PlatformServices..ctor()
   at Microsoft.Extensions.PlatformAbstractions.PlatformServices..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildHostingServices()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()

我的project.json看起來像這樣

    {
  "dependencies": {
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net461": { }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

相同的應用程序,如果針對dotnetcore而不是dotnet461工作正常。 所有MS文檔似乎都說這種情況是可能的並且受到支持。 RTM有什么變化嗎?

如果您首先發布了針對netcoreapp1.0的相同應用程序,然后是net4x版本,那么我認為這是Web Deploy中的一個錯誤。 我在發布到Azure時遇到了類似的問題 - https://github.com/aspnet/Hosting/issues/801#issuecomment-227920473 我通過首先手動刪除目標文件夾中的所有內容然后再次發布針對net4x的應用程序來net4xhttps://github.com/aspnet/Hosting/issues/801#issuecomment-228123238 )。 我認為Web Deploy會留下一些dll或者如果名稱相同則不會更新,然后它們會被選中但是因為它們與目標框架不匹配而失敗,因為它們缺少依賴項。 我還發現,選中Web Deploy中的復選框以刪除目標位置的文件並沒有解決問題,並在此處打開了一個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM