"One or more errors encountered while loading the designer" is making me suicidal! :(

S

sklett

This BUG that is so ridiculous I can't believe they shipped 05 is making my
life hell. I have tried the various solutions found on the web and none of
them have worked thus far. What's even more troublesome is that it appears
that 05 uses these new partial classes which would makes rolling back to 03
not possible.

The error I get when trying to load my Form in the designer is as follows:
----------------------------------------------------------------------------------------------
One or more errors encountered while loading the designer. The errors are
listed below. Some errors can be fixed by rebuilding your project, while
others may require code changes.

Object reference not set to an instance of an object.

at PMD.FirmwareEditor.UIContextControls.UC_ContextConfiguration..ctor() in
C:\PMDRepository\Tools\DQ_Tools\FirmwareEditor\trunk\UIContextControls\UC_ContextConfiguration.cs:line
142
 
T

Tim Wilson

Sounds like something may be going wrong when the designer is attempting to
create an instance of the UC_ContextConfiguration control. Have you gone
through the constructor for the UC_ContextConfiguration class to see if
something might be causing an exception?
 
S

sklett

Awesome, nice catch!

This code was offensive to the designer for some reason
<code>
string ampValues =
ConfigurationManager.AppSettings.Get("UIAmpRangeOptions");
// string[] values = ampValues.Split('|');
</code>

Why? I don't know, by commenting out the second line, it works fine(and
subsequent references to ampValues)

I tried to explicitly initialize the string array with this code
<code>
string[] values = null;
if (values != null)
{
values = ampValues.Split('|');
}
</code>

now it works fine.

Do you see the reason? Is c# getting a little more strict with
initializations? I'm confused still, but I thank you that I no longer have
a gun to my head :) (my whiskey bottle is still empty though, you didn't
fix that)

Have a good weekend!
 
T

Tim Wilson

string ampValues =
ConfigurationManager.AppSettings.Get("UIAmpRangeOptions");
// string[] values = ampValues.Split('|');
</code>
I would assume that the "UIAmpRangeOptions" setting could not be found and
"null" was returned. If you then attempted to call a method (Split) on a
null reference you'd get a NullReferenceException thrown in the constructor,
which, in turn, thwarted the designers attempt to instantiate the control.
<code>
string[] values = null;
if (values != null)
{
values = ampValues.Split('|');
}
</code>
The code in the "if" statement should never be getting executed here.
"values" is set to "null" and then a check to see if "values" does not equal
null is made on the next line. This "if" check should fail every time.

Try looking at the return value of the "AppSettings.Get" call. The return
value, stored in "ampValues", may be "null".

--
Tim Wilson
..NET Compact Framework MVP

sklett said:
Awesome, nice catch!

This code was offensive to the designer for some reason
<code>
string ampValues =
ConfigurationManager.AppSettings.Get("UIAmpRangeOptions");
// string[] values = ampValues.Split('|');
</code>

Why? I don't know, by commenting out the second line, it works fine(and
subsequent references to ampValues)

I tried to explicitly initialize the string array with this code
<code>
string[] values = null;
if (values != null)
{
values = ampValues.Split('|');
}
</code>

now it works fine.

Do you see the reason? Is c# getting a little more strict with
initializations? I'm confused still, but I thank you that I no longer have
a gun to my head :) (my whiskey bottle is still empty though, you didn't
fix that)

Have a good weekend!

Tim Wilson said:
Sounds like something may be going wrong when the designer is attempting
to
create an instance of the UC_ContextConfiguration control. Have you gone
through the constructor for the UC_ContextConfiguration class to see if
something might be causing an exception?

--
Tim Wilson
.NET Compact Framework MVP

making
my none
of to
03
------------------------------------------------------------------------- -
------------------------------------------------------------------------- -
-------------------- error.
I
 

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