Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

c# - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...