1. 程式人生 > >asp.net core 2.0釋出到IIS流程及報錯解決方案

asp.net core 2.0釋出到IIS流程及報錯解決方案

 

我這是個新裝的伺服器,沒有安裝任何軟體。

一、釋出流程

1.安裝AspNetCoreModule託管模組,同時會自動安裝..net core runtime

DotNetCore.2.0.8-WindowsHosting.exe

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.0

2.重啟電腦,或者使用如下命令重啟IIS

net stop was /y
net start w3svc

3.安裝IIS

4.將專案釋出到IIS

5.編輯應用程式池,把.net clr版本設定為無託管程式碼

二、遇到問題

1.瀏覽器執行專案,報錯如下:

HTTP Error 502.5 - Process Failure

 

Common causes of this issue:
• The application process failed to start
• The application process started but then stopped
• The application process started but failed to listen on the configured port

 

Troubleshooting steps:


• Check the system event log for error messages
• Enable logging the application process' stdout messages
• Attach a debugger to the application process and inspect

這個錯誤網上有各種各樣的解決方案,但是苦苦嘗試了將近一天的時間沒有一個適合我的。現在彙總各種解決方案,可能有適合你的:

https://www.cnblogs.com/iiwen/p/9209391.html

https://blog.csdn.net/CuiLanren/article/details/80777488

 

2.檢視windows錯誤日誌資訊如下:

Application 'MACHINE/WEBROOT/APPHOST/FORM' with physical root 'C:\fabu\' failed to start process with commandline 'dotnet .\Cloud.Boss.dll', ErrorCode = '0x80004005 : c0000135.

3.使用dotnet.exe命令dotnet d:\fabu\boss.dll執行專案,報錯如下:

---------------------------
dotnet.exe - 系統錯誤
---------------------------
無法啟動此程式,因為計算機中丟失 api-ms-win-crt-runtime-l1-1-0.dll。嘗試重新安裝該程式以解決此問題。
---------------------------
確定
---------------------------

3.1. 解決3的錯誤的方案是:

安裝Visual C++ Redistributable for Visual Studio 2015 元件
api-ms-win-crt-runtime元件為 MFC 的執行時環境的庫,是用微軟的visual studio C++編譯的,底層也會用到微軟提供的C++庫和runtime庫,安裝Visual C++ Redistributable for Visual Studio 2015 元件即可解決此問題
下載地址:https://www.microsoft.com/en-us/download/details.aspx?id=48145,

如果安裝時報錯如下:

更新windows系統,或者參考文章:https://blog.csdn.net/neochan1108/article/details/78084073

 4.瀏覽器重新輸入專案地址,問題解決。

 總結

為什麼我以前的伺服器沒有遇到這個問題呢,

那是因為我以前的伺服器都裝了sqlserver,他會自動安裝Visual C++ Redistributable for Visual Studio 2015 元件。而我這個專案用的是mysql,就沒有安裝此元件。

其實微軟官網文件已經說明了,只是我沒有看,如下:

 

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?view=aspnetcore-2.0