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...

I've had this problem, too, and it was because I created a new namespace, but the parent namespace contained a class with the same name.


Looks like a bug in VS code's OmniSharp.

Solution for me was to execute command "Restart OmniSharp".

Just do: - ctr shift P - type "Restart OmniSharp" .. hit enter

This fixed it for me.