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

后端 未结 29 1478
深忆病人
深忆病人 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-04 23:56

    I had something similar to this happen in my WPF application. It arose when I was trying to do some cleanup by declaring a namespace that was more descriptive. The problem arose because I had named the namespace in the code-behind (or cs) the same as the Window class. The namespace in the code-behind should have the last section stripped (after the rightmost dot) and used to declare the class and instantiate it. Notice Win below:

    xaml

    code-behind

    namespace FrameApp.UI.Invoice
    {
        public partial class Win : Window
        {
            public Win()
        }
    }
    

    An obvious oversight but it set me back at least an hour with all the errors that appeared.

提交回复
热议问题