How to fix “namespace x already contains a definition for x” error? Happened after converting to VS2010

I had this happen to me about a year ago and I don’t remember exactly what the root cause was, but there are two things you might try:

  1. If it’s an auto-generated file (as ‘Resources.Designer.cs’ tend to be), try deleting it and letting VS re-generate it.
  2. Either separately or in conjunction with #1, select Show All Files in the Solution Explorer or open the solution folder in Windows Explorer – it could be that a version of the file somehow got excluded from the project and is therefor ‘invisible’ to VS but still makes it angry…

Leave a Comment