Error when running a criticality analysis: Object reference not set to an instance of an object.

Product(s): WaterGEMS, WaterCAD
Version(s): CONNECT Edition, V8i
Area: Modeling


When trying to compute a criticality analysis, the following error message is generated:

System.NullReferenceException: Object reference not set to an instance of an object.

at Haestad.Water.Criticality.Support.CustomerMeterSegmentationResults.GetElementListWithAssociatedCustomer()
at Haestad.Water.Criticality.Support.CustomerMeterSegmentationResults.Initialize(Int32 segmentCount)
at Haestad.Water.Criticality.Components.CriticalityStudySegmentationResultsControl.BindResults()
at Haestad.Water.Criticality.Components.CriticalityStudySegmentationResultsControl.Reset(Int32 id)
at Haestad.Water.Criticality.Components.CriticalityStudySegmentationScopeControl.Reset(Int32 id)
at Haestad.Water.Criticality.Forms.CriticalityParentForm.ShowEditor(CriticalityTreeNodeModelBase criticalityNode, CriticalityNodeType type)
at Haestad.Water.Criticality.Forms.CriticalityParentForm.criticalityTreeViewControl_TreeNodeSelectionChanged(Object aobject, TreeNodeSelectionChangedEventArgs e)
at Haestad.Water.Criticality.Components.CriticalityTreeViewControl.OnTreeNodeSelectionChanged(Object aobject, TreeNodeSelectionChangedEventArgs e)
at Haestad.Framework.Windows.Forms.Components.TreeViewControl.OnTreeNodeSelectionChanged(Object sender, TreeNodeSelectionChangedEventArgs e)
at Haestad.Framework.Adapting.TreeEditorModelBase.OnTreeNodeSelectionChanged(ITreeNodeModel anodeModel, ITreeNodeModel previousNodeModel)
at Haestad.Framework.Adapting.TreeEditorModelBase.set_SelectedNodeModel(ITreeNodeModel value)
at Haestad.Framework.Windows.Forms.Components.TreeViewControl.m_treeView_AfterSelect(Object sender, TreeViewEventArgs e)
at System.Windows.Forms.TreeView.OnAfterSelect(TreeViewEventArgs e)
at System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
at System.Windows.Forms.TreeView.WmNotify(Message& m)
at System.Windows.Forms.TreeView.WndProc(Message& m)
at Haestad.Framework.Windows.Forms.Components.TreeViewEx.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


This issue may be related to the some of the supporting files associated with the model. With that in mind, first close the model and browse to where the model files are saved. Create a new folder and copy just the .wtg and .wtg.sqlite files into the new folder, then open the model from the new folder location. 

If this doesn't help, close the model but leave the program open (with no model file open). Go to File > Database Utilities > Compact Database (or Tools > Database Utilities > Compact Database in WaterGEMS V8i). Select the database file associated with the model and, when prompted, choose the option to purge the model to save space. Then open the model and see if the issue occurs.

If the issue still occurs, please upgrade to the latest version of WaterGEMS. Testing has found cases similar to this no longer occur as of CONNECT Edition Update 1 (build The following link has steps to upgrade to the latest version: Downloading OpenFlows | Hydraulics and Hydrology Software

See Also

Running a Criticality Analysis