gpt4 book ai didi

asp.net - 面向完整 dotnet 框架的 ASP.NET Core Web 应用程序是否在 IIS 中工作?

转载 作者:行者123 更新时间:2023-12-04 17:44:54 25 4
gpt4 key购买 nike

我正在尝试将在完整框架 (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 的应用程序来修复它。再次( https://github.com/aspnet/Hosting/issues/801#issuecomment-228123238 )。我认为如果名称相同,Web Deploy 会留下一些 dll 或不更新,然后它们被拾取但失败,因为它们与目标框架不匹配并且它们的依赖项丢失。我还发现选中 Web Deploy 中的复选框以删除目的地的文件并没有解决问题,并就此打开了一个问题。

关于asp.net - 面向完整 dotnet 框架的 ASP.NET Core Web 应用程序是否在 IIS 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38237576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com