星期五, 2月 14, 2025

[SSRS] DataSource 重覆,造成無法開啟資料集功能

開發 SSRS 報表時,要新增資料集時,VS 突然拋出錯誤訊息,訊息如下
詳細錯誤訊息
如需叫用 Just-In-Time (JIT) 偵錯的詳細資料, 請參閱本訊息結尾處 (而非這個對話方塊) 的資訊。

************** 例外狀況文字 ************** 

System.NullReferenceException: 並未將物件參考設定為物件的執行個體。 
於 Microsoft.ReportDesigner.Design.GenericObjectDataSource.InitializeVB(ISchemaType schemaType) 於 Microsoft.ReportDesigner.Design.DesignUtil.AddTablesFromSchema(ISchemaType schemaType, Type parentType, String propertyName, IDictionary objectDataSources, IServiceProvider serviceProvider) 於 Microsoft.ReportDesigner.Design.DesignUtil.GetVBObjectDataSources(XmlSchema[] schemaDataSources, IServiceProvider serviceProvider) 於 Microsoft.ReportDesigner.Data.Local.DataSetSynchronizer.<GetProjectGenericObjectDataSources>d__11.MoveNext() 於 Microsoft.ReportDesigner.Data.Local.DataSetSynchronizer.<GetSynchableDataSources>d__7.MoveNext() 於 Microsoft.ReportDesigner.Data.Local.Dialogs.Pages.DataSetGeneralPage.LoadDataSources() 於 Microsoft.ReportDesigner.Data.Local.Dialogs.Pages.DataSetGeneralPage.LoadData() 於 Microsoft.ReportDesigner.Data.Local.Dialogs.DataSetDialog.OnLoad(EventArgs e) 於 System.Windows.Forms.Form.OnCreateControl() 於 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) 於 System.Windows.Forms.Control.CreateControl() 於 System.Windows.Forms.Control.WmShowWindow(Message& m) 於 System.Windows.Forms.Control.WndProc(Message& m) 於 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

簡單測試後發現新開 Project 或是現有其他 Project 去新增報表或修改現有報表都可以正常開啟資料集 GUI 畫面,只有該 Project 上會拋出該錯誤訊息,同事在版控上發現某個 commit 開始就有該現象,還剛好是我 commit 的,從該 commit change 沒有發現問題,完全沒有頭緒。

洗澡時突然想到,不會是報表更名造成的吧,查看資料夾內實際檔案發現,該報表使用的 DataSource 有兩個,實際檔案名稱雖然有差異,但各個 DataSource 內容只有檔案名稱大小寫差異,把更名前的 DataSource 刪除後,資料集 GUI 就完全恢復正常。
重覆測試後確定報表名稱更名,並不會直接影響 DataSource,也確認在報表內刪除 DataSource 並不會直接刪除實體 DataSource 檔案,直接刪除 Project 內的 DataSource 才會刪除實體 DataSource 檔案,猜測是該 DataSource 可能因為版控關係,該檔案不在 Project 內,又新增同名 DataSource 造成。

該 commit 是一個月前,期間也經歷三張報表開發,沒想到就突然異常。

沒有留言:

張貼留言