2017年12月11日 星期一

System.ArgumentOutOfRangeException: 指定的引數超出有效值的範圍

早上Windows10 Update 更新後,Debug程式時,不管怎麼把程式簡化,都還是跑出來這個錯誤:System.ArgumentOutOfRangeException: 指定的引數超出有效值的範圍。

問了Google大神後,原來又是微軟給苦命工程師出的狀況題,似乎是源自於IISExpress 安裝的問題。

https://developercommunity.visualstudio.com/content/problem/59516/vs-2017-152-cant-debug-aspnet-projects.html

This is caused by IISExpress shim installation failure on recent win10 update. In the meantime, please try the following two regkey to work around the issue.

'/' 應用程式中發生伺服器錯誤。

指定的引數超出有效值的範圍。
參數名稱: site

描述: 在執行目前 Web 要求的過程中發生未處理的例外狀況。請檢閱堆疊追蹤以取得錯誤的詳細資訊,以及在程式碼中產生的位置。

例外狀況詳細資訊: System.ArgumentOutOfRangeException: 指定的引數超出有效值的範圍。
參數名稱: site

原始程式錯誤:

在執行目前 Web 要求期間,產生未處理的例外狀況。如需有關例外狀況來源與位置的資訊,可以使用下列的例外狀況堆疊追蹤取得。

堆疊追蹤:


[ArgumentOutOfRangeException: 指定的引數超出有效值的範圍。
參數名稱: site]
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, 
PolicyLevel policyLevel, Exception appDomainCreationException) +327

[HttpException (0x80004005): 指定的引數超出有效值的範圍。
參數名稱: site]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +752
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +144
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(
IIS7WorkerRequest wr, HttpContext context) +245


解決的方法:
1. 以系統管理員身份執行「命令提示字元」視窗。
2. 再將下面兩行命令分別COPY 再執行,就可以了
reg add HKLM\Software\WOW6432Node\Microsoft\InetStp /v MajorVersion /t REG_DWORD /d 10 /f
reg add HKLM\Software\Microsoft\InetStp /v MajorVersion /t REG_DWORD /d 10 /f


1 則留言: