次の方法で共有


Intermittently Loosing Intellisense in the code behind editor inside visual studio .net

 

Issue

====

One of my colleagues was loosing intellisense in the code behind editor for a particular ASPX page intermittently in visual studio .net 2003.

Cause

=====

Later we found out that he edited the InitializeComponent method by adding the code below:

private void InitializeComponent()

{

  if (Session["AnyVariable"] == null)

    Server.Transfer("frm.aspx");

  this.Load += new System.EventHandler(this.Page_Load);

}

Steps taken to find the root cause

=======================

  1. Opened up new visual studio instance.
  2. Go to Tools -> Debug Processes.
  3. Attach devenv.exe associated with faulty project.
  4. Then go to Debug menu, and select Exceptions.
  5. For each Exception listed, select the option, “Break into the debugger”.
  6. After that open up the problematic ASPX file. Opening up that file resulted into the following exception:

A first chance exception of type 'System.ComponentModel.Design.Serialization.CodeDomSerializerException' occurred in microsoft.visualstudio.dll

Additional information: The designer cannot process the code at line 40:

if (Session["AnyVariable"] == null)

  Server.Transfer("frm.aspx");

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.

Resolution

=======

Removed the code from the InitializeComponent method.