strange error message that try block does not catch

  • Thread starter Thread starter profnachos
  • Start date Start date
P

profnachos

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.
 
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.

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.
 
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>
 
Back
Top