473,320 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
Jun 27 '08 #1
8 3475
On Apr 17, 9:51*am, Bharathi Harshavardhan <bharathi8...@gmail.com>
wrote:
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?
Jun 27 '08 #2
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
Jun 27 '08 #3
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
Jun 27 '08 #4
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
Jun 27 '08 #5
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(Mouse EventArgs 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/Visual...dbackID=251486

http://forums.microsoft.com/MSDN/Sho...54298&SiteId=1

Thanks,
Bharathi

Jun 27 '08 #6
On Thu, 19 Jun 2008 01:43:16 -0700, Bharathi Harshavardhan
<bh**********@gmail.comwrote:
I removed DoEvents call from Click Event Handler. Still the I could
get the obj ref error.
Are you displaying a modal dialog in an event handler for the control?
[...]
I read few articles related to this and got to know that this is the
Unhandled Exception in NumericUpDown Control

https://connect.microsoft.com/Visual...dbackID=251486

http://forums.microsoft.com/MSDN/Sho...54298&SiteId=1
Those articles seem to make pretty clear what the issue is. Are you
saying you _still_ get the exception, even when you take into account the
information in those articles and avoid calling DoEvents() (either
implicitly or explicitly)?

Pete
Jun 27 '08 #7
Yes. I am getting the error even after removing the DoEvents() method
call.

Thanks,
Bharathi
Jun 27 '08 #8
On Mon, 23 Jun 2008 06:14:02 -0700, Bharathi Harshavardhan
<bh**********@gmail.comwrote:
Yes. I am getting the error even after removing the DoEvents() method
call.
That's not what I asked. Calling DoEvents() explicitly is one way to
cause the issue. But it's not the only issue. Another example is
displaying a modal dialog, which does the equivalent of DoEvents()
implicitly. I specifically asked if you are doing that, but you neglected
to answer that question.

Really, without a concise-but-complete code sample that reliably
demonstrates the issue, it's not possible to say how you could fix the
issue. It does sound like it's a known issue with the control, but it
also sounds like there are ways to avoid triggering the bug. With as
little information as you've provided, there's no way for anyone else to
provide suggestions as to how to avoid the bug.

Pete
Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris | last post by:
Hi, I followed the the aricle http://support.microsoft.com/default.aspx?scid=kb;en-us;321525 and was able to execute a dts package in vb.net. I replaced all the "Console.WriteLine" with "msgbox"....
9
by: tym | last post by:
HELP!!! I'm going round the twist with this... I have a VB6 application which is using DAO to access a database (Please - no lectures on ADO, I know what I'm doing with DAO!!) Ok, problem...
17
by: VM | last post by:
In my Windows app, I'm running a batch process that's composed of a FOR loop that'll run 15,000 times (datatable row count), copy cthe data of each row -3 fields- to a struct, and send the strct to...
5
by: Srinivas Kollipara | last post by:
Hey guys, In my project one place I am using Application.DoEvents() and waiting for 5 minutes to finish my required task in that block. My project need to run for almost 60 hours continuously to...
3
by: Lumpierbritches | last post by:
I have an application my partner wrote that would allow an autoresponse to any Mapi compliant email that apparently in .Net won't, can someone assist me with fixing this? Here is the code: ...
1
by: Viet | last post by:
I don't know if this is the right forum for my question but here goes: I am converting a VB6 app to VB.NET and I would like to use Threads and Threadpools. This main app (1) executes two other sub...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
1
by: CodeSeeker | last post by:
I have an application, which uses pop3 to read the messages from the mailbox, and it has been working fine for so many year. We recently have started changing this application to use java mail IMAP 4...
3
by: Sarah | last post by:
Hi - Please be gentle. I am quite new to visual basic, but I have been going through tutorials and reading up. I found a code snippet on the internet that I wanted to see if I could re-purpose...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.