Microsoft KB Archive/814357

= BUG: You receive an error message if you change the case of a control name on the form =

Article ID: 814357

Article Last Modified on 2/3/2006

-

APPLIES TO


 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition

-



SYMPTOMS
You may receive an error message when you build a project on a Windows application if you do the following things:
 * Set the Localizable property of the form to True.
 * Set the Form Language property to a value other than default.
 * Change the case of a control name on the form.

You receive the following error message:

Resource transformation for file 'FormName.resx' failed. Item has already been added. Key in dictionary: &quot;NewControlName.&quot; Key being added: &quot;ControlName.&quot;

This bug occurs only when you change the case of a control name on the form. You may not receive the error when you change the name of the controls.



CAUSE
When you set the Form Language property to a value other than default, Microsoft Visual Studio .NET converts the language dependent properties to appropriate languages. These property values are stored in a resource file with .resx extensions. When you modify the name of a control, all the related keys are stored with the new name in the resource file, and Visual Studio .NET deletes the old key entries. When you change only the case of the control name, Visual Studio .NET adds the new keys entry, but it does not delete the old key entries. This bug occurs because the resource file contains more than one entry for the control.



WORKAROUND
To work around this problem, delete the old key entries in the resource (.resx) file. To do this, follow these steps:
 * 1) Open Visual Studio .NET.
 * 2) On the File menu, point to Open, and then click File.
 * 3) Locate the Form1.resx file, and then click OK.

Form1.resx is displayed.
 * 1) Locate the original key values, and then manually delete them from the data list.

For example, you have a button named Button1. You modify the name of this button to BUTTON1. The key values for both Button1 and BUTTON1 are in Form1.resx. Remove all the entries of Button1, and then rebuild the project.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



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.
 * 1) On the View menu, click Properties.
 * 2) In the Properties window, set the Localizable property to True.
 * 3) In the Properties windows, click Language, and then set the value to Japanese.
 * 4) From the toolbox, drag a button onto the form.
 * 5) Change the name of the button from Button1 to BUTTON1.
 * 6) On the Build menu, click Build Solution.

You receive the error in the &quot;Symptoms&quot; section of this article.

