![](/img/trans.png)
[英]ASP.NET CORE 3.0 application to IIS under Default Web Site/MySite does not work properly
[英]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
的應用程序來net4x
( https://github.com/aspnet/Hosting/issues/801#issuecomment-228123238 )。 我認為Web Deploy會留下一些dll或者如果名稱相同則不會更新,然后它們會被選中但是因為它們與目標框架不匹配而失敗,因為它們缺少依賴項。 我還發現,選中Web Deploy中的復選框以刪除目標位置的文件並沒有解決問題,並在此處打開了一個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.