How to correctly refactor a control's namespace in ASP.NET

Someone asked on Stack Overflow:

I have this situation which is rather frustrating… I have some user controls where I would like to rename their namespace. However, when I do this my build fails because the .designer.cs file for pages that use the controls is still generating control declarations with the OLD namespace. Is this coming from the assembly? I can’t rebuild because this is obviously creating a compile-time error (those controls no longer exist in the old name). I’ve tried wiping out the entire file, but it is always regenerated with the old namespace.

How do I get around this without manually editing every .designer.cs file???

I posted the following answer, which was chosen as the accepted answer:

In the past I have used these steps with some success, but I’ve also had to monkey around a lot, so I maybe missing some steps. (its been a while since I had to deal with this issue)

  1. Close Visual Studio
  2. Delete all designer.cs files (backup just in case ;))
  3. Fire up Visual Studio again and try a rebuild

Originally posted on Stack Overflow — 0 upvotes (accepted answer). Licensed under CC BY-SA.

signed letter b

Dad. Geek. Gamer. Software developer. Cloud user. Old Car enthusiast.  Blogger.


Top Posts


profile for Nate on Stack Exchange, a network of free, community-driven Q&A sites
a proud member of the blue team of 512KB club
Thoughts, opinions, and ideas shared here are my own. © 2026 Nate Bross.