網頁

2018年7月25日 星期三

.Net網站部署後發生"錯誤碼:-2146232576"的問題

去裝機花了好久時間在這問題上,問了N個人沒人遇過,找資料也找不到,回家後覺得是否是Keyword下錯,用"錯誤碼:-2146232576"才找到類似的問題。依ASP.NET 網站部署後發生 ryslon 編譯錯誤-2146232576所述,看起來是Microsoft.Net.Compilers這個Library版本的問題。貼上ASP.NET 網站部署後發生 ryslon 編譯錯誤-2146232576摘錄的StackOver的回應如下:

The culprit is the Microsoft.Net.Compilers package, used to support modern C# syntax/features (version 6.0, 7.0) in your project and in Razor views in particular. Depending on its version, the package requires a particular minimum version of the full .NET framework to be installed on a machine in question.

For instance, the 2.2.0 package requires .NET 4.6+. Even though your project is targeting say .NET 4.5.2, you probably have the latest .NET installed on your development machine, and everything goes just fine. The remote deployment machine only has .NET 4.5.2 installed, and when your ASP.NET application tries to compile resource (e.g. views) at run time, you get error -2146232576.
回去查了下自己用的,沒想到用到2.6.1 ,難怪出問題,畢竟主機只用了.Net framework 4.5.1。乖乖的找1.3.2來用。其實可以用2.0.1,但怕怕的。
 


參考網址:
ASP.NET 網站部署後發生 ryslon 編譯錯誤-2146232576