Design time error: Code generation failed

F

Frankie D.

I have got the following message in the designer window if I try to save my
form.

"Code generation for property 'MenuImage' failed. Error was: Object
reference not set to an instance of an object.

MenuImage is a property of NCTMenuItem object and its value is set to "none"
in the property window int the designer. The definition of the property is in
an other assembly (NCTlib.dll, Softkey.cs)and looks like the following:

private Image menuImage = null;

public Image MenuImage
{
get
{
return menuImage;
}
set
{
menuImage = value;
}
}

I think the designer try to create the following line in the
myForm.designer.cs file and this operation fails at design time:

this.miFile.MenuImage =
((System.Drawing.Image)(resources.GetObject("miFile.MenuImage")));

Sometimes after I have changed Softkey.cs, for a short time everything is
good in the designer window of MyForm.

Some project data:

CF 2.0
VS 2008 SP1

I have found the description of the same error, but there was no answer for
my problem:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=175236&SiteID=1

Please help!

Thanks in advance,

Frankie
 
A

Alberto Salvati

Hi, Frankie.
Some day ago I see same error in vs2005/cf2.0 sp1.
In my form I've 4 picturebox and this form works fine.
But, after some code change, compiler give me this error.
I've solved remoging pictureboxes from form, rebuild (not BUILD..),
add pictureboxes, setup image for each object and rebuild.

HTH

A.Salvati
 
C

Chris Oswald

I have got the following message in the designer window if I try to save my
form.

"Code generation for property 'MenuImage' failed. Error was: Object
reference not set to an instance of an object.

MenuImage is a property of NCTMenuItem object and its value is set to "none"
in the property window int the designer. The definition of the property is in
an other assembly (NCTlib.dll, Softkey.cs)and looks like the following:

private Image menuImage = null;

public Image MenuImage
        {
            get
            {
                return menuImage;
            }
            set
            {
                menuImage = value;
            }
        }

I think the designer try to create the following line in the
myForm.designer.cs file and this operation fails at design time:

this.miFile.MenuImage =
((System.Drawing.Image)(resources.GetObject("miFile.MenuImage")));

Sometimes after I have changed Softkey.cs, for a short time everything is
good in the designer window of MyForm.

Some project data:

CF 2.0
VS 2008 SP1

I have found the description of the same error, but there was no answer for
my problem:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=175236&SiteID=1

Please help!

Thanks in advance,

Frankie

I was able to get my image to work by adding this XML to the
designtimeattributes file for the parent control

<Property Name="Image">
<Category>Design</Category>
<RefreshProperties>Repaint</RefreshProperties>
<DesignerSerializationVisibility>Visible</
DesignerSerializationVisibility>
<NotifyParentProperty>true</NotifyParentProperty>
</Property>
 

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