今天在一部剛剛好的電腦上發布一個做好的網站(Net 2.0),VS2005 Team suite英文版, 裝了TFS方便團隊開發, 在VS裡面可以運行與調試, 產生也沒提示出錯, 但到發布網站那部總出現一個錯誤, 使用發布過程中斷:Index was outside the bounds of the array。
感覺有點熟悉這個錯誤, 因為好久前我就試過這問題, 後來怎解決怎也想不起,在百度與google裡找了差不多一個小時, 發現原來是差一個補丁, 真暈倒, 這時就想起來原因了。 發現工作中這些小問題還是要記下來, 以方便日後回憶。
這個補丁叫 hotfix補丁, 在Visual Studio SP1中有可能會遇到。 在這裡直接下載。
當這個設定完成後, 開始發布到IIS設定的目錄上。 運行發現介面十分簡結, 與我們做的完全不符。 只有一行紅色大字型與幾行小黑字型, 如下:
Server Application Unavailable
The web application you are attempting to access on this web server is currently unavailable.Please hit the "Refresh" button in your web browser to retry your request.
Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.
這時候去看一下日誌, 發現錯誤記錄檔中記錄 aspnet_wp.exe (PID: 2164) stopped unexpectedly.
原因是這電腦先裝了IIS-->SQL2005-->VS2005-->VS6,因為每一個.net framework都有一個自己的aspnet_regiis版本,可能IIS上面用到的是1.1或其它的, 這裡你發布了2.0的程式來這裡運行, 沒有匹配到2.0的版本。 所以只出現幾句簡結的字型。
那隻有在運行中輸入C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i 安裝了aspnet。提示OK後就可以了。