Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / November 2006

Tip: Looking for answers? Try searching our database.

strange error message that try block does not catch

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
profnachos@gmail.com - 15 Nov 2006 05:30 GMT
When I step through code and come to the line in the try block

try
{
    chkJobCompleted.Checked = dispatchJob.JobCompleted;
}
catch(Exception ex)
{
     MessageBox.Show(ex.Message);
}

I get a pop up message consistently that says "Object reference not set
to an instance of an object"

Several observations to note:

* the checkbox (chkJobCompleted) is NOT null
* the object dispatchJob is NOT null.
* why doesn't the try block catch it?  Why doesn't it go into the catch
block?  Why do I get a popup message despite the try block?
* after I click okay on the popup message box, the code goes on.

It does not make sense to me.  Thanks for all your help.
Michael C - 15 Nov 2006 06:13 GMT
> I get a pop up message consistently that says "Object reference not set
> to an instance of an object"
[quoted text clipped - 8 lines]
>
> It does not make sense to me.  Thanks for all your help.

Are you sure it doesn't go into the catch, you do have a messagebox there
and that is the behaviour you're describing? Does changing the checked
property cause another event to fire that causes this exception? Have you
got exception handling turned off for this? (Go to Debug-Exceptions menu to
check). Is this try-catch inside another try-catch? Does putting it in a
seperate function fix the problem? I have read about a problem with try
catches inside try catches but not sure if it's been fixed or not.
Rad [Visual C# MVP] - 15 Nov 2006 13:15 GMT
Perhaps the problem is the JobCompleted property in particular of your
jobCompleted object that is the problem -- have you verified that it is not
null>
Signature


Bits. Bytes.
http://bytes.thinkersroom.com
------------------------------

> When I step through code and come to the line in the try block
>
[quoted text clipped - 19 lines]
>
> It does not make sense to me.  Thanks for all your help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.