我将应用程序部署到服务器时遇到问题。
我收到错误:
HTTP错误502.5 - 进程失败
在日志文件中,我可以看到:
未处理的异常:System.IO.FileLoadException:无法加载文件 或汇编' System.Core,Version = 4.0.0.0,Culture = neutral, 公钥= b77a5c561934e089&#39 ;.定位组件的清单 定义与程序集引用不匹配。
这是我的project.json
{
"userSecretsId": "aspnet-travelingowe-c23d27a4-eb88-4b18-9b77-2a93f3b15119",
"dependencies": {
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.SpaServices": "1.1.0-*",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
"Microsoft.Extensions.Logging": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.1.0-preview4-final",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
"Hangfire.AspNetCore": "1.6.8",
"HangFire.SqlServer": "1.6.8",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Serilog": "2.4.0",
"Serilog.Extensions.Logging": "1.4.0-dev-10138",
"Serilog.Extensions.Logging.File": "1.0.1-dev-00008",
"MailKit": "1.10.2",
"Microsoft.AspNetCore.Mvc": "1.1.1",
"Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
"System.Xml.XDocument": "4.3.0",
"Microsoft.Extensions.Configuration.Binder": "1.1.0",
"System.Collections.Immutable": "1.3.0"
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
"Microsoft.DotNet.Watcher.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final",
"Microsoft.Extensions.SecretManager.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"
},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
},
"imports":
"dnxcore50"
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"compile": {
"exclude": [ "node_modules" ]
}
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"appsettings.json",
"ClientApp/dist",
"Views",
"web.config",
"wwwroot"
],
"exclude": [
"wwwroot/dist/*.map"
]
},
"scripts": {
"prepublish": [
"npm install",
"node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod",
"node node_modules/webpack/bin/webpack.js --env.prod"
],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"tooling": {
"defaultNamespace": "Travelingowe"
}
}
你知道如何解决它吗?
更新: 现在我有一个错误:
未处理的异常:System.IO.FileLoadException:无法加载文件 或汇编' System.Core,Version = 4.0.0.0,Culture = neutral, 公钥= b77a5c561934e089&#39 ;.定位组件的清单 定义与程序集引用不匹配。 (例外 HRESULT:0x80131040)at Microsoft.Extensions.Configuration.EnvironmentVariables.EnvironmentVariablesConfigurationProvider.Load(IDictionary的 envVariables)at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 提供者) Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()at MyProject.Program.Main(String [] args)in E:\ Projects \ MyProject \ Program.cs:第15行
如上所示,它使用我在本地使用的服务器上的本地路径。我该如何更改?
答案 0 :(得分:1)
安装.NET Core Windows Server Hosting捆绑包后,您是否重新启动了IIS?
这就是我正式设置IIS以运行.net core:
的方法来源:https://docs.microsoft.com/en-us/aspnet/core/publishing/iis
答案 1 :(得分:0)
似乎project.json正在引用其中一个仍然不支持.Net Core 1.1的软件包。
从project.json中删除"System.Collections.Immutable": "1.3.0"
,因为从Nuget图库文档看,它似乎尚不支持.net Core 1.1
答案 2 :(得分:0)
为解决此问题,我将这些行添加到了.csproj文件中
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
答案 3 :(得分:0)
IIS无法运行ASP.NET Core站点-HTTP错误502.5
您的问题是一个错误的web.config文件:
<aspNetCore requestTimeout="02:00:00"
processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout"