05 January 2009

when *.designer.cs is out of sync

In asp.net every page or control has three parts:
  • asp markup part (*.aspx, *.ascx) - that is where you build a structure of you web page or control;
  • *.cs - that is where you put your code behind
  • *.design.cs - that is werd side which suppose to be controlled by IDE (Visual Studio), it contains all identities of every control on your page.
It happens, it happens too often to me that *.desing.cs file get out of sync with mark-up. It usually happens when I rename or move User Control and fix namespace etc. Code doesn't compile, or could not find a control by name. 

Today I came quite severe case of such misbehaviour and maybe I spent 30 minutes or so back and forward and trying to resolve it.
I found solution browsing forums:
  1. Delete the desing.cs file
  2. Right Click on the file, Convert to Web Application.

It might react with Generic Exception or even NotImplemented Exception. :) Do not worry - Exit Studio, delete all files in bin and obj folders and Open your solution again. Then repeat attempt to Convert to Web Application.