BUG: Windows Forms Resource Editor cannot open inherited forms (814732)



The information in this article applies to:

  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)

SYMPTOMS

The Windows Forms Resource Editor (Winres.exe) is a visual layout tool that helps localize Windows Forms. You use the .resource file or the .resx file as input to Winres.exe. When you use Winres.exe to edit inherited Windows Forms, you may receive the following error message:
An error occurred while loading the document. Fix the error, then try loading the document again. The error message follows: Value does not fall within the expected range.

CAUSE

WinRes.exe uses the assembly mentioned in the .resource file or .resx file to edit the form. The file contains an entry for the inherited class and for the assembly name (for example, System.Windows.Form). When the resource is loaded, WinRes.exe checks for assembly in the Global Assembly Cache (GAC), and then displays the resource by instantiating the object. However, for inherited Windows Forms, the entry in the file is the inherited base form, and the assembly name is the application name. The error occurs because WinRes.exe does not find the assembly in the GAC or in the directory where WinRes.exe is located when it reads from the inherited Windows Forms file.

WORKAROUND

To work around this issue, use one of the following methods:
  • Add the assembly in the GAC by entering the following command:
    gacutil -I <assembly name>

-or-

  • Copy the assembly in the directory where WinRes.exe is located. For example, put the assembly in C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Windows application by using Visual Basic .NET or Visual C# .NET.

    By default, Form1 is created.
  2. On the View menu, click Properties.
  3. In properties windows, click Localizable, and then set the value to True.
  4. On the Build menu, click Build Solution.
  5. In Solution Explorer, right-click Project, point to Add, and then click Add Inherited Form.
  6. On the Add New Item window, click Open.
  7. On the Inheritance Picker window, click OK.

    Form2 is added to the project.
  8. In the Properties windows, click Localizable and set the value to True.
  9. On the Build menu, click Build Solution.
  10. Open the Visual Studio .NET command prompt, type winres, and then press the ENTER key.

    Winres.exe is opened.
  11. On the File menu, click Open.
  12. Click to select Form2.resx, and then click Open.

    The error in the "Symptoms" section of this article is displayed.

REFERENCES

For more information, visit the following Microsoft Web site:

Windows Forms Resource Editor (Winres.exe)
http://msdn.microsoft.com/library/en-us/cptools/html/cpgrfwindowsformsresourceeditorwinresexe.asp

Modification Type:MinorLast Reviewed:1/25/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kbvs2002sp1sweep kbWindowsForms kbForms kbbug KB814732 kbAudDeveloper