stormist stormist - 1 month ago 8
C# Question

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

Specifically the error occurs in the

Resources.Designer.cs
:


Error 2 The namespace 'ModulusFE' already contains a definition for 'StockChartX' Resources.Designer.cs 11 21 ModulusFE.StockChartX


I've googled this and am still quite confused. Does anyone know anything I might try?

I have tried rebuilding and cleaning, as well as renaming the
Resources.Designer.cs
file in hopes that it would rebuild, but no luck.

The top of the code says this:

// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.225
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>


Any ideas whatsoever would be appreciated.

Answer

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