Search code examples
c#compact-frameworkopennetcf

OpenNETCF.Button2: Code generation for property 'BackgroundImage' failed


There is Button2 control on form. I have issue with changing its name:

Property value is not valid

or

Code generation for property 'BackgroundImage' failed

Button2 control Misc properties:

Button2 control Misc properties

How can I solve this problem?

As I mentioned I should add to my project DesignTimeAttributes.xmta file with Build Action: None?

I use .NET Compact Framework 3.5/Visual Studio 2008/OpenNETCF Smart Device Framework 2.3 library (Community Edition)


Solution

  • I had the same problem. I removed all initialisation code (beside the call to InitializeComponent) in the constructor but still had this problem. I could solve the issue by adding a DesignTimeAttributes.xmta file with the following contents:

    <Class Name="OpenNETCF.Widows.Forms.Button2">
        <DesktopCompatible>true</DesktopCompatible>
        <DesignTimeVisible>true</DesignTimeVisible>
        <Property Name="BackgroundImage">
          <Category>Misc</Category>
          <DefaultValue>
            <Type>System.Drawing.Image, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Type>
          </DefaultValue>
          <Description>The background image displayed for the control.</Description>
        </Property>
      </Class>