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

后端 未结 29 1361
深忆病人
深忆病人 2020-12-04 23:10

Specifically the error occurs in the Resources.Designer.cs:

Error 2 The namespace \'ModulusFE\' already contains a definition for \'Sto

相关标签:
29条回答
  • 2020-12-05 00:02

    This may be a bit of an edge case, but we've run across this in our development environment from time to time. We had to setup a custom culture in Windows to support en-HK. Windows 8.1 now supports this culture natively as does Windows 2012 R2, but older machines need to have the culture created. Any machine that does not have this culture setup will get this error reported. The solution is to create the culture on the machine (We have a console app created for this purpose) and everything starts working again.

    0 讨论(0)
  • 2020-12-05 00:02

    I had this issue, but mine was slightly different to the issues mentioned here. I was cleaning up my project and moving around some classes into new folders. I had a 'AddFilter' class that I moved into an 'AddFilter' folder - so I had actually wound up with a class that was sharing the name of a namespace. This was a bit tricky to spot at first because I couldn't find any other classes that it was conflicting with; it was conflicting with the namespace instead.

    0 讨论(0)
  • 2020-12-05 00:03

    I had this same problem and it was due to naming a function in the code behind the same as my tool. Simple mistake but something to keep in mind as well.

    0 讨论(0)
  • 2020-12-05 00:03

    This error happened to me when I was using Visual Studio Code. I think it must have been because I was trying to build a project while there was an executable running in the same bin\debug folder. I stopped the executable, closed the folder, reopened, rebuilt, and the error went away.

    0 讨论(0)
  • 2020-12-05 00:04

    This just happened to me. What happened was that I duplicated a project that was originally under source control. Although I properly renamed everything, the file permissions on all the files were still set to read-only. When I started modifying some form controls, Visual Studio automatically created a Resource1 file because the original Resource file was read-only.

    What I did to fix this was as follows:

    1. allow write permissions on the project files.
    2. deleted the original Resource file
    3. Ctrl-A for all form elements, then Ctrl-X to cut them.
    4. Save the form.
    5. Ctrl-V to paste them all back.
    6. Save the form.

    I had to do this because the auto-generated code wasn't updating on it's own, so I "forced" it to update by making a change to the form. Not doing this left a bunch of code from form elements that no longer existed prior to changing the file permissions.

    0 讨论(0)
  • 2020-12-05 00:04

    I had a similar issue however found a different solution than what I have read. I came to my fix after reading P Walker's answer.

    My issue happened when I named my resource file for Japanese language incorrectly. Long story short I was trying to create a Resource for Japanese but I accidentally named it localized.jp.resx. I then realized that the iso language code is ja not jp for Japanese. Once I changed the file name to localized.ja.resx and deleted everything that was in the designer file it fixed my problem.

    This is what fixed my problem hopefully it helps someone else.

    0 讨论(0)
提交回复
热议问题