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

Re: Problem with the Windows Forms Designer... by Uri

Uri
Wed Jul 14 07:02:05 CDT 2004

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.

electroVik wrote:

> 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

Re: Problem with the Windows Forms Designer... by bobino

bobino
Thu Jul 15 09:24:24 CDT 2004

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.

Uri Dor <tablul@newsgroups.nospam> wrote in message news:<uso6kHZaEHA.3596@tk2msftngp13.phx.gbl>...
> 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.