views:

36

answers:

0

I have a problem with Visual Studio 2010 and Outlook Addin 2010 project (.NET 4 target). I've added a form region to my project and then I've changed Localizable property to true. Now if I close my form region and reopen it, I'm getting this VS error page:

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.

This actually happens when I change any property in Form Region or Ribbon if the code is targeted for .NET 4. In projects targeted for .NET 3.5 everything is in order. Here's the example code that this error refers to was created by VS and it's a part of FormRegion.Designer.cs. It breaks on ApplyResources line (if I comment it out then everything is ok).

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);
}

If I choose to ignore the error and force VS to load visual editor then I'm getting another error:

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

At first I though it's a problem with my code (I have my project migrated from VS2008 and Outlook 2007). But then I created a new project for VS2010 and Outlook 2010 and I have the same problem there.

Steps to reproduce it:

  1. Create a new Outlook 2010 Addin project in Visual Studio 2010 (.NET 4)
  2. Add a new FormRegion item to a project (it doesn't matter for which item you enables it, it also doesn't matter if it's adjoined or separate form region)
  3. Open new item properties and change Localizable property to true
  4. Close item and reopen it