[EIP] 除錯 ‘Ede.Uof.EIP.SystemInfo.Current’ 的類型初始設定式發生例外狀況 UOF2 一等一科技

by | 11 月 9, 2026 | 一等一UOF系統, 程式 | 0 comments

瀏覽量:0

快速解法 : 重啟IIS就會好

錯誤訊息

錯誤畫面如下

進入事件檢視器後,會發現有資料庫連線失敗的錯誤

Exception information: 
    Exception type: TypeInitializationException 
    Exception message: 'Ede.Uof.EIP.SystemInfo.Current' 的類型初始設定式發生例外狀況。
   於 Ede.Uof.EIP.SystemInfo.Current.get_Theme()
   於 _Login.Page_PreInit(Object sender, EventArgs e) 於 Z:\Builds\20\UofAgile\3.Setup\src\Web\Ede.Uof.Web\Login.aspx.cs: 行 728
   於 System.Web.UI.Page.OnPreInit(EventArgs e)
   於 System.Web.UI.Page.PerformPreInit()
   於 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

建立連接至 SQL Server 時,發生網路相關或執行個體特定的錯誤。找不到或無法存取伺服器。確認執行個名稱是否正確,以及 SQL Server 是否設定為允許遠端連線。 (provider: Named Pipes Provider, error: 40 - 無法開啟至 SQL Server 的連接)
   於 Ede.Uof.Utility.Data.DatabaseHelper.HandleExceptions(Exception ex) 於 Z:\Builds\20\UofAgile\3.Setup\src\Lib\Utility\Ede.Uof.Utility.Data\DatabaseHelper.cs: 行 616
   於 Ede.Uof.Utility.Data.DatabaseHelper.ExecuteScalar(String query, CommandType commandtype, ConnectionState connectionstate) 於 Z:\Builds\20\UofAgile\3.Setup\src\Lib\Utility\Ede.Uof.Utility.Data\DatabaseHelper.cs: 行 414
   於 Ede.Uof.Utility.Configuration.SettingPO.Get(String item) 於 Z:\Builds\20\UofAgile\3.Setup\src\Lib\Utility\Ede.Uof.Utility.Configuration\SettingPO.cs: 行 20
   於 Ede.Uof.EIP.SystemInfo.Current..cctor() 於 Z:\Builds\20\UofAgile\3.Setup\src\Lib\EIP\Ede.Uof.EIP.SystemInfo\Current.cs: 行 27

指定的網路名稱無法使用。

我有請INFA看一下防火牆連線LOG,目前是正常的,我查了一下失敗開始剛好是防火牆更新作業開始,然後它就死了,不過正式環境沒事,所以我猜是偶發狀況

如何重現?

只要跟DB連線斷掉,系統就會變這樣。

錯誤原因推估

原因是Ede.Uof.EIP.SystemInfo.Current 這個是Static的,也就是所謂的靜態函數,因為連線不到資料庫導致建構時候失敗拋出例外,.NET Framework 在靜態建構函式拋出例外後,同一個應用程式網域(AppDomain)內不會重新執行該建構函式。因此,即使資料庫已恢復連線,後續登入請求讀取 Current.Theme 時仍會失敗。

重啟 IIS 會讓站台在新的 AppDomain 中重新載入,使 Current 得以重新初始化。確認資料庫連線恢復後,也可回收 UOF 站台所屬的應用程式集區(App Pool),再開啟登入頁確認是否恢復。

0 Comments

Submit a Comment

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *