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.