An unhandled exception of type 'System.NullReferenceException' occ

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a C# application that periodically gets the above exception when
attempting to call ShowDialog on a particular dialog.

I have created a new project, copied the dialog files (.cs and .resx) to the
new project and I can't get it to happen in the new project.

I have tried everything I can think of, including putting try...catch around
every possible call I can think of to no avail. It still stops.

Any help would be appreciated. Not sure where to look now.
 
Some additional information:

The dialog that is being called in the Load() routine of the main class of
my application. If I call another dialog (a dummy one), before the dialog I
was having a problem with, the problem goes away. Here is the code snippet.

StartupForm startForm = new StartupForm();
** Form1 f = new Form1();
** f.ShowDialog(this);
if (startForm.ShowDialog(this) == DialogResult.Cancel)

The lines with the ** cause the error which occurs on the * line to go away.

Hmmm???? What might be going on?
 
Back
Top