Specifically the error occurs in the Resources.Designer.cs
:
Error 2 The namespace \'ModulusFE\' already contains a definition for \'Sto
This happened to me, I noticed that there was actually another class with that same name under the same namespace "OtpService.Models.Request", so all I did was to just change the namespace of the 2nd class to "OtpService.Models.Request.ExtraObj". I did this because I did not want to change the name of the conflicting class to anything else.
Unfortunately, none of the other answers helped. My problem specifically occurred in a WPF project.
The problem arose when I created a folder under the MainWindow
folder, which effectively created a namespace something like ProjectName.MainWindow.Folder
.
Now, I believe because of some static designer code, Visual studio gets confused between the class MainWindow
and the namespace Project.MainWindow.Folder
.
As a solution, I moved the Folder
out of MainWindow
. Looking at the Class View or the solution/project helps to recognize what namespaces and classes within them exist.
I had a similar problem and resolved it by removing any copies/backups of the .cs file from the directory.
This is an old question but I didn't find the fix I used, so I've added it here.
In my case it was a namespace with the same name as a class in the parent namespace.
To find this, I used the object browser and searched for the name of the item that was already defined.
If it won't let you do this while you still have the error then temporarily change the name of the item it is complaining about and then find the offending item.
I had this problem. It was due to me renaming a folder in the App_Code directory and releasing to my iis site folder. The original named folder was still present in my target directory - hence duplicate - (I don't do a full delete of target before copying) Anyway removing the old folder fixed this.
when you have tried everything else and still get the same trouble, there is a way out; however it will be tedious and need careful preparation.
Start another new project using existing files, or edit the project .csproj file if you are proficient in editing csproj (need backup). I will list steps for new project.