我是靠谱客的博主 寒冷星月,最近开发中收集的这篇文章主要介绍An error occurred while starting the application.An error occurred while starting the application.,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

An error occurred while starting the application.

一、.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=".logsstdout" />
</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:FTPDialysisWebApiDialysis.WebApi.xml'. File name: 'G:FTPDialysisWebApiDialysis.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:FTPDialysisWebApi Now listening on: http://localhost:22365 Application started. Press Ctrl+C to shut down.
View Code

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

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

  

 

posted on 2018-06-13 15:30  无影飞絮剑 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/itslives-com/p/InternalServerError.html

最后

以上就是寒冷星月为你收集整理的An error occurred while starting the application.An error occurred while starting the application.的全部内容,希望文章能够帮你解决An error occurred while starting the application.An error occurred while starting the application.所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(39)

评论列表共有 0 条评论

立即
投稿
返回
顶部