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