0

In my project I've got 3 forms - main form, form with list of some object(in dropdownlist), form where i can add new object.

In main form I can invoke form with list of objects and form with add func. And I do it like this

Form2 f2 = new Form2(some_param);
f2.ShowDialog();

When f2 is opened I can see drop down list with objects and a button to add new object(using form with add func). In this dialog I decided to add new object

void click1(object sender,EventArgs e)
{
  Form3 f3 = new Form3(some_param); // want to add new object and then show in dropdownlist
  f3.ShowDialog();
  radDropDownList1.Items.Clear();  // I close the form and catch here NullReferenceException
  InitDropDown();
}

What's the problem? What causes NullReferenceException?

When I show form3 by pressing button on main form and then close - it works normal and main form doesn't catch any exceptions when form 3 is closed.

lapots
  • 12,553
  • 32
  • 121
  • 242
  • 2
    Enable exceptions and you will see where from exceptions come. Go in Visual Studio -> Debug -> Exceptions, mark CLR Exceptions – sll Dec 19 '12 at 19:12
  • 1
    It has helped. I've found what cause the error. – lapots Dec 19 '12 at 19:26

1 Answers1

0

I had the same issue and sll comment is what helped me too. So i am just reposting his comment as an anwser so others can see this thread as solved.

Official Answer
Enable exceptions and you will see where from exceptions come. Go in Visual Studio -> Debug -> Exceptions, mark CLR Exceptions - sll

TinkeringMatt
  • 181
  • 1
  • 9