更改任何表单区域/功能区属性会破坏Visual Studio编辑器

时间:2010-06-11 08:15:10

标签: .net visual-studio-2010 vsto outlook-addin outlook-2010

我遇到Visual Studio 2010和Outlook Addin 2010项目(.NET 4目标)的问题。我已经在项目中添加了一个表单区域,然后我将Localizable属性更改为true。现在,如果我关闭我的表单区域并重新打开它,我将收到此VS错误页面:

To prevent possible data loss before loading the designer, the following errors 
must be resolved: 
The variable 'resources' is either undeclared or was never assigned.

当我在表格区域或功能区中更改任何属性时,实际上会发生这种情况。如果代码是针对.NET 4的。在针对.NET 3.5的项目中,一切都是有序的。 以下是此错误引用的示例代码是由VS创建的,它是FormRegion.Designer.cs的一部分。它在ApplyResources行中断(如果我发表评论,那么一切正常)。

private void InitializeComponent()
{
    System.ComponentModel.ComponentResourceManager resources = 
        new System.ComponentModel.ComponentResourceManager(typeof(FormRegion1));
    this.SuspendLayout();
    // 
    // FormRegion1
    // 
    resources.ApplyResources(this, "$this");
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.Name = "FormRegion1";
    this.FormRegionShowing += 
        new System.EventHandler(this.FormRegion1_FormRegionShowing);
    this.FormRegionClosed += 
        new System.EventHandler(this.FormRegion1_FormRegionClosed);
    this.ResumeLayout(false);
}

如果我选择忽略错误并强制VS加载可视化编辑器,那么我会收到另一个错误:

Cannot open a designer for the file because the class within it does not inherit 
from a class that can be visually designed. 

起初我虽然我的代码存在问题(我的项目已从VS2008和Outlook 2007迁移)。但后来我为VS2010和Outlook 2010创建了一个新项目,我遇到了同样的问题。

重现它的步骤:

  1. 在Visual Studio 2010(.NET 4)中创建新的Outlook 2010 Addin项目
  2. 向项目添加一个新的FormRegion项目(您启用它的项目无关紧要,如果它是相邻的或单独的表单区域也无关紧要)
  3. 打开新的商品属性并将Localizable属性更改为true
  4. 关闭项目并重新打开

0 个答案:

没有答案