The namespace 'x' already contains a definition for 'y'

I am trying to create an aspx file inside a project folder. I try to create inside a folder called "NIITS", but when I create, I get an error,

The namespace 'fig' already contains a definition for 'NIITS' 

I see this error in the cs and designer files. What could be the problem?

code behind:

 namespace fig.NIITS.Ora { public partial class Index : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } } 
+4
source share
1 answer

One of the immediate reasons that come to mind may have removed the β€œpartial” from NIITS.designer.cs or NIITS.cs. This will force the compiler to believe that you do not have two files of the partial class, but two separate classes with the same name.

Basically, find your files for the / ... classes that create the "NIITS" entry in your "fig" namespace. This can happen if, for example, when you have a class fig.NIITS and try to create a class fig.NIITS. In any case, the "NIITS" part is already used as the class name, and this cannot be resolved if you mean the NIITS class or the "NIITS" namespace.

It is not true that you receive this error message when you try to create an ASPX template file. I expected this to not happen in files that do not contain elements to be installed in the namespace. But with a code file (or a similar class file) this may be the reason.

+2
source

All Articles