Microsoft KB Archive/944315

= Error message when try to add a new form to a Visual C# project in Visual Studio 2005: &quot;The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified&quot; =

Article ID: 944315

Article Last Modified on 12/10/2007

-

APPLIES TO


 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Express Edition

-



SYMPTOMS
You upgrade a Microsoft Visual C# project from Microsoft Visual Studio 2003 to Microsoft Visual Studio 2005. When you try to add a new form to the project, you may receive an error message that resembles the following:

The designer cannot process the code at line 32: this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again.

Additionally, when you try to open the existing forms in the project, you receive the same error message.

Note This problem occurs in design mode. When you compile the project, you receive no error messages.



WORKAROUND
To work around this problem, use one of the following methods.

Method 1
Check the default namespace of the project. Make sure that the default namespace does not contain the &quot;.System&quot; string.

Method 2
Change the code as follows:

Original string

System.Windows.Forms Replacement string global::System.Windows.Forms



Keywords: kbqfe kbprb KB944315

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.