ASP.NET Core publish error: An error occurred while starting the application

匿名 (未验证) 提交于 2019-12-03 01:10:02

问题:

I tried to publish my ASP.NET Core application on Windows Server 2008 R2 but I get this error: "An error occurred while starting the application."

Without any more description!

What can I do?

回答1:

Please take a look at this post: https://scottsauber.com/2017/04/10/how-to-troubleshoot-an-error-occurred-while-starting-the-application-in-asp-net-core-on-iis which will give you a good starter kit to get basic log informations when this kind of error appear.
It may be a bad startup configuration or related to the .NET Core runtime installed but very difficult to say without more technical information.



回答2:

  1. try to enable logging in web.config

<aspNetCore stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />

  1. if no logs, check event viewer there will be something like:

Could not create stdoutLogFile C:\inetpub... ErrorCode = -2147024891.

  1. Try to setup website on another drive e.g. D:\inetpub\website

in my case it works fine from another drive but it does not work with C:\inetpub\website I suppose this is kind of security permissions trouble.

If it does not help you should at least see the logs that lead you further.

Although i'm Administrator on the pc and other websites under .NET Framework 4.7.1 are running OK from C:\inetpub\ the asp.net core site has the issue



回答3:

Althouth there many things that could go wrong and the proper way is to actually troubleshoot the error, my case was simpler:

I forgot to configure the release output path for Swagger

You can to that by following these steps:

  1. Right click your project
  2. Click Properties
  3. Click on the Build tab
  4. And at the Output section check the XML documentation file checkbox.

This will autocomplete the path with an XML file, but you can change that to whatever you want.

I copy-paste the solution from https://mycodepad.wordpress.com/2018/08/23/publishing-asp-net-core-an-error-occurred-while-starting-the-application/



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!