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

后端 未结 29 1359
深忆病人
深忆病人 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

    if you have 2 versions of any of your code file (*.cs, *.vb etc.) inside your "app_code" folder then you will get this error because dot net would include both the files in your project and will get 2 different implementations of the same class (because of same name in 2 versions of same code file in app_code folder)

    0 讨论(0)
  • 2020-12-04 23:58

    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.

    0 讨论(0)
  • 2020-12-04 23:58

    Me too got this error, When I change my WPF project's Target Framework to Framework Version 4.0 Client Profile -> Framework 4.0. It's solved by itself.

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

    I had an xaml file with the following definition

    <Window x:Class="mm2.Views"
       .etc..
    />
    

    mm2.Views was the name of a namespace in my app.

    To fix it, I correctly renamed the xaml object:

    <Window x:Class="mm2.Views.RecordedTracks"
       .etc..
    />
    
    0 讨论(0)
  • 2020-12-05 00:01

    I had a similar problem (Universal project, Visual Studio 2015), I solved it with the following changes:

    In App.xml.cs was (it was ok):

    namespace Test.Main {
    

    Wrong, old version of App.xml:

    x:Class="Test.Main"
    

    Good, new version of App.xml:

    x:Class="Test.Main.App"
    
    0 讨论(0)
  • 2020-12-05 00:02

    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.

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