BUG: The Visual Studio .NET IDE stops responding with too many classes in one .cs file (315473)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

This article was previously published under Q315473

SYMPTOMS

If you add too many classes (for example, approximately 1,000) in a single C# (.cs) file while the file is open in the Visual Studio .NET Integrated Development Environment (IDE), the IDE may appear to stop responding (hang).

CAUSE

This behavior can occur because the IDE may take a long time to parse the source code in the open .cs file.

RESOLUTION

To work around this issue, use one or more of the following methods, as necessary:
  • In the IDE, click Options on the Tools menu. In the Options window, expand the Text Editor node, expand the C# node, and then select the Formatting node. In the right pane, click to clear the Automatically format completed constructs and pasted source check box, and then click OK.If the .cs file is open in the IDE, close the file. (You do not have to close the project.) Open the .cs file in Notepad. Add the classes, save the file, and then quit Notepad. You can now open the modified .cs file in the IDE.Do not put too many classes in one single .cs file while the file is open in the IDE. Separate the classes into different .cs files.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Problem

  1. Create a new C# console application project in the Visual Studio .NET IDE.
  2. Start Notepad, and then add the following source code:
    class a1
    {
      int i;
    }
    class a2
    {
      int i;
    
    }
    Repeat the preceding definition for classes a3 to a998. Then, add the following classes to complete the 1,000 classes:
    class a999
    {
      int i;
    }
    class a1000
    {
      int i;
    }
    					
  3. Go to the console application project in the IDE. Open the Class1.cs file. Copy all of the source code from the Notepad window, and then paste it into the Class1.cs file in the section preceding class "Class1" and the first curly brace ({) after "namespace". Note that the IDE appears to stop responding.

Modification Type:MajorLast Reviewed:7/29/2005
Keywords:kbvs2002sp1sweep kbbug kbnofix KB315473 kbAudDeveloper