'System.NullReferenceException' not breaking in MDI ChildForm

  • Thread starter Mike in Paradise
  • Start date
M

Mike in Paradise

I am developing some forms that use multiple accessors to
get information from within user created controls.


MainForm is Parent

JobForm is a MDI child

It has a user Control called MaterialControl

Eg.
MaterialControl has an accessor JobinProgress

Which Accesses a Job Class, which in Turn Access a
Materials class which in Turn accesses the AddMaterial
Method

Eg:

JobinProcess.Job.Materials.AddMaterial

JobinProcess has accessor to Job

Job has an accessor to Materials

Materials has the Actual Method.

My problem is when I do not have something initialized
properly during development and one of these accessors
contains a null value.

During debugging it just drops out of the MDi child Form
being processed and breaks in the Parent form where the
the MDI child form is being created, with
the 'System.NullReferenceException' showing in the Main
MDI Parent Form as opposed to staying in the MDI child
Form with an error on the line generating the error.

This requires me stepping through the code line by line
to figure out which line is generating the error so I can
fix it.

Do I have something wrong in my debugging setup. It
seems like it is only in the case of an null in an
accessor that it does this. All other times it breaks
into the code where the error is as opposed to dropping
me out of the child form.

Any help or nudges in the right direction would be
appreciated.
 
G

Guest

In VS.NET goto Debug->Exceptions & click on CLR Exceptions Node
Inside System namespace, you will find "NullReferenceException", see the
setting of "what to do when Exception is not handled",

Select "Break into the debugger" & your problem will be solved
Since, the exception is not handled, the execution returns to the
calling proc's try catch block :)

HTH
Kalpesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top