Problem with the Windows Forms Designer...

E

electroVik

I have a custom control called, lets say, SportBillyComboBox, which
inherits from ComboBox. When I add my control from the toolbox, I get
an error (System.NullReferenceException : Object not set to an
instance of an object) on my form replacing the control, but my newly
added SportBillyComboBox is there (even if "you can't see it" - under
the Exception) and seems to work fine in compilation and in runtime.
But when I next use the Windows Forms Designer to change or add
something, it automatically adds those lines in the designer :

this.SportBillyComboBox1.Items.AddRange(new object[] {
((object)(resources.GetObject("SportBillyComboBox1.Items"))),
((object)(resources.GetObject("SportBillyComboBox1.Items1"))),
((object)(resources.GetObject("SportBillyComboBox1.Items2"))),
((object)(resources.GetObject("SportBillyComboBox1.Items3")))});

Even if I never asked in the Designer to add some items in the
collection, it magically appears in my InitializeComponent Code -
TADAM! But worse of all, it doesn't add the necessary entries into my
Form1.resx resources file so the code crashes on the newly
automatically magically added line. Sure, I can always erase those
lines, but every time I change something in my form, it add those
lines again and again and again...

Anyone having a fix for this one? Even my first problem (when I add
the control to my form... the little "System.NullReferenceException"
error) is disturbing!

Do you have any clue?

Thank you,

electroVik
 
U

Uri Dor

regarding the 1st problem, you should run MSDEV as the debug
application, turning on "break into debugger" under Exceptions in the
outer MSDEV, then in the inner MSDEV load your project - that should
stop where the null reference occurs.
 
E

electroVik

That did not change a thing... the Exception is still witten in red in
the Windows Form Designer and the program still crashes because the
Items are not added in the resources file.
 

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