Help needed regarding: Application.DoEvents() throws objectreference not set error

  • Thread starter Thread starter Bharathi Harshavardhan
  • Start date Start date
B

Bharathi Harshavardhan

Hi,

I have an application in which I have used Application.DoEvents()
method in the click event of a NumericUpDown. This particular method
is throwing "Object reference not set to an instance of an object"
error.. Does anyone have any idea about it?

Regards,
Bharathi
 
Hi,

I have an application in which I have used Application.DoEvents()
method in the click event of a NumericUpDown. This particular method
is throwing "Object reference not set to an instance of an object"
error.. Does anyone have any idea about it?

Regards,
Bharathi

Hi,

Can you post some code? where it's happening?

Why are you calling DoEvents?
 
The StackTrace and/or the nested InnerExceptions might be illuminating -
but it might also be useful to illustrate what you are trying to do with
sample code.

As Ignacio alludes; DoEvents() is not an ideal method; it has various
associated issues, most notably reentrancy. Useful in VB6 days when you
only had one thread, but usually there are cleaner ways to code in C#.

Marc
 
Hi,

This is a bug with the .net numeric up/down control. Clicking on the
up/Down button on this control continously would throw Object
reference error. I have used Application.DoEvents() event in the
Click event Handler of the up/down control. This particular error
cannot be resolved currently because this is a bug with the Numeric Up/
Down control.

Bharathi
 
Out of interest, what makes you conclude that the up/down control is the
cause? You have broken the natural execution flow by forcing DoEvents -
I'd argue that the first thing to do is "not call DoEvents"; if it stops
erroring, then your code was the problem...

Marc
 
Hi Marc,

I removed DoEvents call from Click Event Handler. Still the I could
get the obj ref error.

When we click continuously on a NumericUpDown Control, I get a null
reference exception.

System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Windows.Forms.UpDownButtons.StopTimer()
at System.Windows.Forms.UpDownButtons.EndButtonPress()
at System.Windows.Forms.UpDownButtons.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

I read few articles related to this and got to know that this is the
Unhandled Exception in NumericUpDown Control

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=251486

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1554298&SiteId=1

Thanks,
Bharathi
 
Yes. I am getting the error even after removing the DoEvents() method
call.

Thanks,
Bharathi
 
Back
Top