I have found exceptions reported in our application specific Event log that are related to the UltraWinTree and/or the UltraTreeNode. At this point I have not been able to reproduce it but it appears in the log daily and I hoping someone might be able to suggest a possible cause. Here's the stack trace:
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
Exception Type: NullReferenceException
Message: Object reference not set to an instance of an object.
Stack Trace:
at Infragistics.Win.UltraWinTree.UltraTreeNode.get_IsLastViewableSibling()
at Infragistics.Win.UltraWinTree.NodeClientAreaUIElement.ShouldDrawVerticalConnectorToBottom(TreeNodeUIElement nodeUI)
at Infragistics.Win.UltraWinTree.NodeClientAreaUIElement.PositionChildElements()
at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
at Infragistics.Win.UIElement.VerifyChildElements(Boolean recursive)
at Infragistics.Win.UIElement.VerifyChildElements()
at Infragistics.Win.UltraWinTree.UltraTreeUIElement.PositionChildElements()
at Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean verify, Boolean syncMouseEntered)
at Infragistics.Win.ControlUIElementBase.get_CurrentCursor()
at Infragistics.Win.UltraControlBase.get_Cursor()
at Infragistics.Win.UltraWinTree.UltraTree.get_Cursor()
at System.Windows.Forms.Control.WmSetCursor(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
We are using version 9.2.20092.2083 of the WinForms controls.
One other thing, is that I am using one of my personal accounts to report this. The company that I work for has valid licenses for this software but the developer responsible for the licenses information and who usually would post question/help requests is no longer associated with the company. I don't currently have an account associated with those licenses (or his account information), how would I go about creating an account that associates me with the company's licenses?
I have also come across this issue and have the following sample that reproduces the described issue. In order to reproduce the issue I hooked up a control with an ultra tree set to dock to fill with a panel of two buttons (Create/Delete) docked to the bottom of the control. To reproduce I clicked the 'Create' button and then scrolled the control down some distance (will not reproduce when the scrollbar has not moved) after which I clicked delete and moved the cursor in/out of the tree area. I do not see anything incorrect in the provided example as all updates of the control are performed on the UI thread. No data is modified outside of the UI thread and the only thing the thread is doing is allowing the message pump to execute while posting UI notifications.
const int TOTAL_NODES = 25000; public Form1() { InitializeComponent(); } private void ubtnCreate_Click(object sender, EventArgs e) { ultraTree1.Nodes.Clear(); for (int i = 0; i < TOTAL_NODES; i++) { string text = string.Format("Test{0}", i); ultraTree1.Nodes.Add(text, text); } } private void ubtnDelete_Click(object sender, EventArgs e) { SetEnabled(false); new Thread(DeleteProc).Start(); } private void DeleteProc() { try { StartDelete(); for (int i = TOTAL_NODES - 1; i >= 0; i--) { Delete(i); } } finally { EndDelete(); } } private void StartDelete() { if (InvokeRequired) { Invoke(new Action(StartDelete)); return; } Application.UseWaitCursor = true; ultraTree1.BeginUpdate(); } private void EndDelete() { if (InvokeRequired) { Invoke(new Action(EndDelete)); return; } ultraTree1.EndUpdate(); Application.UseWaitCursor = false; SetEnabled(true); } private void Delete(int index) { if (InvokeRequired) { Invoke(new Action(Delete), index); return; } ultraTree1.Nodes.RemoveAt(index); } private void SetEnabled(bool enable) { if (InvokeRequired) { Invoke(new Action(SetEnabled), enable); return; } ubtnCreate.Enabled = enable; ubtnDelete.Enabled = enable; }
const int TOTAL_NODES = 25000;
public Form1() { InitializeComponent(); }
private void ubtnCreate_Click(object sender, EventArgs e) { ultraTree1.Nodes.Clear(); for (int i = 0; i < TOTAL_NODES; i++) { string text = string.Format("Test{0}", i); ultraTree1.Nodes.Add(text, text); } }
private void ubtnDelete_Click(object sender, EventArgs e) { SetEnabled(false); new Thread(DeleteProc).Start(); }
private void DeleteProc() { try { StartDelete(); for (int i = TOTAL_NODES - 1; i >= 0; i--) { Delete(i); } } finally { EndDelete(); } }
private void StartDelete() { if (InvokeRequired) { Invoke(new Action(StartDelete)); return; } Application.UseWaitCursor = true; ultraTree1.BeginUpdate(); }
private void EndDelete() { if (InvokeRequired) { Invoke(new Action(EndDelete)); return; } ultraTree1.EndUpdate(); Application.UseWaitCursor = false; SetEnabled(true); }
private void Delete(int index) { if (InvokeRequired) { Invoke(new Action(Delete), index); return; } ultraTree1.Nodes.RemoveAt(index); }
private void SetEnabled(bool enable) { if (InvokeRequired) { Invoke(new Action(SetEnabled), enable); return; } ubtnCreate.Enabled = enable; ubtnDelete.Enabled = enable; }
This is currently being investigated by Infragistics. Figured I would update this post in case anyone else was researching this issue.
Hi Lin,
As far as I know, there was never any response to my reply on this thread. So I can only assume that the original poster was using threading and that was the case of the issue.
Are you using multiple threads in your application? If so, then that is almost certainly the problem and not a bug in the control. You really cannot use threading and DataBinding together safely except in very rare and limited cases.
Phalbert said:I'm updating the control on a background thread using invoke and in most case it works, but occasionally it just crashes.
What exactly are you doing on the background thread? If your background thread is modifying the DataSource of any control (grid, tree, or any other control that is bound to it), then there is absolutely no way that your code can be safe.
Using an Invoke is not enough, because you are not in control of the communication between the bound control and the data source. There will be all sorts of things happening between the data source, the BindingManager, and the bound control that you cannot invoke because they happen automatically.
Hello
I'm getting this exact same random problem. Can update 20 time no worries, and then for no reason it crashes and throws an application exception.
I'm updating the control on a background thread using invoke and in most case it works, but occasionally it just crashes.
I replaced the tree with a grid and there's no crashing problem, so it's only the Tree that is causing the problem. I can't use the grid because it does not give me the layout i need...
I notice the problem is an "Object reference not set to an instance of an object." exception and not a 'Cross thread" exception, so I was wondering if further examination was required around what could create a NULL reference in your code base given the call stack.
My stacktrace is below. Any help greatly appreciated.
STACK TRACE
Object reference not set to an instance of an object.
Source Assembly: Infragistics2.Win.UltraWinTree.v10.3
Method: get_IsLastViewableSibling
at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize)
at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)
at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe)
at Infragistics.Win.UltraWinTree.UltraTree.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)