一、.net core 发布后的站点启动报错如下

An error occurred while starting the application.

.NET Core 4.6.26328.01 X64 v4.0.0.0    |   Microsoft.AspNetCore.Hosting version 2.0.3-rtm-10026    |    Microsoft Windows 10.0.16299    |   Need help?

二、解决办法,先打开iis日志。web.config 修改如下(重点背景色黄色)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension, LongDate" />
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\GP.Core.WebAPI.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>

  一般情况下我们发布后,都会存在这段代码,但是要把 stdoutLogEnabled="false" 换成 stdoutLogEnabled="true" 才能在根目录记录文本日志,查看异常原因。log日志文件夹需要手动创建!

三、刷新站点页面,查看发布根目录发现多了一个logs文件夹,打开里面的stdout_xxx.log文件,打开就可以看到我们站点启动失败的原因(eg:某些日志文件nlog.config或者文档xml等没有复制输出到发布目录)。

Application startup exception: System.IO.FileNotFoundException: Could not find file 'G:\FTP\DialysisWebApi\Dialysis.WebApi.xml'. File name: 'G:\FTP\DialysisWebApi\Dialysis.WebApi.xml'    at System.IO.Win32FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)    at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)    at System.Xml.XmlSystemPathResolver.GetEntity(Uri uri, String role, Type typeOfObjectToReturn)    at System.Xml.XmlTextReaderImpl.FinishInitUriString()    at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)    at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)    at System.Xml.XmlReader.Create(String inputUri)    at System.Xml.XPath.XPathDocument..ctor(String uri, XmlSpace space)    at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions.<>c__DisplayClass24_0.<IncludeXmlComments>b__0()    at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions.CreateSwaggerProvider(IServiceProvider serviceProvider)    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)    at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvider provider)    at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)    at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass3_0.<UseMiddleware>b__0(RequestDelegate next)    at Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()    at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() Hosting environment: Production Content root path: G:\FTP\DialysisWebApi Now listening on: http://localhost:22365 Application started. Press Ctrl+C to shut down.

四、因为项目在startup的时候没有读到nlog.config这个文件导致的错误。解决办法:

  在开发环境中,把这个文件的属性配置成 “生成操作:内容”和 “复制到输出目录:始终复制” 就可以了。

  

An error occurred while starting the application.的更多相关文章

  1. .Net Core Web应用发布至IIS后报“An error occurred while starting the application”错误

    An error occurred while starting the application. .NET Core X64 v4.1.1.0    |   Microsoft.AspNetCore ...

  2. [转].Net Core Web应用发布至IIS后报“An error occurred while starting the application”错误

    本文转自:http://www.cnblogs.com/TomGui/p/6438686.html An error occurred while starting the application. ...

  3. NETCore项目报错 An error occurred while starting the application

    在发布到IIS的webApi项目中,运行时报出以上错误, 解决方法: 1.打开发布目录文件夹,找到web.config文件 2.打开web.config找到stdoutLogEnabled=" ...

  4. Launch4j:An error occurred while starting the application.解决方案

    长期使用Processing 2.X进行开发,突然有一天Processing 1.5.1打不开了,报错如下: 按[确定]后窗口消失,但是任务管理器中的“javaw.exe”并没有消失..... 试过各 ...

  5. An error occurred while starting a transaction on the provider connection. See the inner exception for details.

    用EntityFramework循环操作数据时,报了如下错误 An error occurred while starting a transaction on the provider connec ...

  6. Runtime Error---Description: An application error occurred on the server....

    [原]Runtime Error---Description: An application error occurred on the server.... 2010-1-7阅读2010 评论3 D ...

  7. SharePoint Error occurred in deployment step 'Recycle IIS Application Pool': 0x80070005:拒绝访问

    错误出现的前提:多个用户在一台机器上做开发,使用非系统管理员账号时会出现,因为一般创建网站集时指定管理员为系统管理员: 使用 Visual Studio 2010 部署时报错:Error occurr ...

  8. Jmeter:运行报:Error occurred starting thread group :线程组, error message:Invalid duration 0 set in Thread Group:线程组, see log file for more details

    最近在用jmeter做压测,上周五压测的脚本,今天早晨结束后. 点击同样的脚本,运行就报Error occurred starting thread group :线程组, error message ...

  9. Eclipse无法启动报An internal error occurred during: "reload maven project". java.lang.NullPointerException

    由于没有正常关机导致eclipse无法将数据正常写入配置文件导致无法启动.报这样一个异常 An internal error occurred during: "reload maven p ...

随机推荐

  1. 20164322韩玉婷 -----Exp2 后门原理和实践

    一.后门的概念       后门是指那些绕过安全性控制而获取对系统访问权的程序 二.基础问题回答 (1)例举你能想到的一个后门进入到你系统中的可能方式? 非官方网站下载应用程序时,该应用程序可能绑定了 ...

  2. CentOS 7安全加固

    本次实验使用的centos 7 版本 一.查找系统中是否存在空密码账户 1.使用命令: awk -F: '($2==""){print $1}' /etc/shadow 直接查看. ...

  3. Mac os x 系统的发展史

    ·Mac OS 9:发布时间:1999年 于1999年发布的Mac OS 9操作系统(图片来自互联网) 在OS X之前,1999年发布的Mac OS 9看起来就是一个普通的桌面操作系统.并且现在已经被 ...

  4. win10 uwp 读取resw资源文件

    ResourceContext resourceContext = ResourceContext.GetForViewIndependentUse(); ResourceMap resourceMa ...

  5. 温度转换 II

    描述 温度的刻画有两个不同体系:摄氏度(Celsius)和华氏度(Fabrenheit). 请编写程序将用户输入华氏度转换为摄氏度,或将输入的摄氏度转换为华氏度. 转换算法如下:(C表示摄氏度.F表示 ...

  6. 前端基础:canvas概述

    1:并不是所有的浏览器都支持canvas,若是不支持则浏览器会弹出 <canvas>Update your browser to enjoy canvas</canvas> 浏 ...

  7. java数据结构之HashSet和HashMap(java核心卷Ⅰ读书笔记)

    增加 删除 remove方法,可以删除指定的一个元素. 查找 ********************* **************************** HashSet既不可以用 0 1 2 ...

  8. k8s基于CA签名的双向数字证书认证(三)

    1.设置kube-apiserver的CA证书相关的文件和启动参数   1)创建CA证书和私钥相关的文件 openssl genrsa -out ca.key openssl req -x509 -n ...

  9. DNS 负载均衡

    相关文章: 文章 网址 一个域名可以绑定多个IP吗?由此引发的调查 https://ask.zkbhj.com/?/article/139

  10. python随机数学习笔记

    #coding:utf-8 import random # random.randint(1,10)产生1,10的随机整数 for i in range(1,5): ranint = random.r ...