Tuesday, 16 March 2010

ASP.NET Code Behind Intellisense Not Working

This has been infuriating.

So many times when developing web applications using Visual Studio 2008 Enterprise Edition or Visual Studio Web Developer Express 2008, the intellisense in the code behind would stop working, and when the project is deployed any reference to page controls would result in a null reference exception.

There are quite a few things to try:

  • Close Visual Studio (Or VSWDE) and delete the intellisense files which are normally stored in your Windows profile.
  • Open the IDE again and rebuild the project.
  • Check that your aspx page is properly wired up to your code behind in the page directive.
  • Delete the project dll file in the bin folder and rebuild your project.
  • This is the one that worked for me: Check that there is a designer file associated with that page. If there is not, then in Visual Studio, right click on the project in Solution Explorer and click Convert to Web Application. That should regenerate the designer file for you.

If your intellisense isn't working and your code behind just can't seem to reference the controls, there are a lot of things that could be wrong. But if you try all of those, then hopefully you'll be back coding again instead of angrily trying to figure out what's wrong.