【问题标题】:OpenNETCF.Button2: Code generation for property 'BackgroundImage' failedOpenNETCF.Button2:属性“BackgroundImage”的代码生成失败
【发布时间】:2013-10-08 06:59:56
【问题描述】:

表单上有Button2控件。我在更改其名称时遇到问题:

Button2 控件杂项属性:

我该如何解决这个问题?

正如我所提到的,我应该将 Build Action: None 添加到我的项目 DesignTimeAttributes.xmta 文件中?

我使用 .NET Compact Framework 3.5/Visual Studio 2008/OpenNETCF Smart Device Framework 2.3 库(社区版)

【问题讨论】:

  • 所以在设计器中设置BackgroundImage时失败了?如果你在代码中设置它会发生什么?
  • 我已经解决了这个问题。这与 OpenNETCF 无关。我在表单构造函数中有太多初始化代码,它也调用父表单的构造函数。强烈建议重构我的代码
  • 呃!讨厌这样的东西。您可以删除按钮,保存并关闭所有错误的项目,然后将其打开并添加另一个同名按钮吗?

标签: c# compact-framework opennetcf


【解决方案1】:

我遇到了同样的问题。我删除了构造函数中的所有初始化代码(除了对 InitializeComponent 的调用),但仍然存在这个问题。 我可以通过添加包含以下内容的 DesignTimeAttributes.xmta 文件来解决该问题:

<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>

【讨论】:

    猜你喜欢
    • 2011-12-12
    • 1970-01-01
    • 1970-01-01
    • 2015-04-15
    • 1970-01-01
    • 2012-11-11
    • 2021-07-24
    • 2015-01-29
    • 1970-01-01
    相关资源
    最近更新 更多