Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Compiler Error Message: CS0433: The type 'proto.Class1' exists in both
what could the problem



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="proto.Login" Src="Class1.cs" %>


if (username.Text.Equals("") || password.Text.Equals("") || level.Text.Equals("") || name.Text.Equals("") || employeeNo.Text.Equals("") || surname.Text.Equals("") || gender.Text.Equals(""))
           {
               string alert = "Please fill all fields as they are all required";
               ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('" + alert + "')</script>");
           }
           else
           {
               Class1 validate = new Class1();


What I have tried:

I tried creating new class and removing Src=class but error still persist.
Posted
Updated 21-Mar-22 0:33am
Comments
Richard MacCutchan 21-Mar-22 6:36am    
You have two definitions of Class1 in your application. Please add the complete text of the error message. It is also a very bad idea to use the default names of classes in an application. Change it from Class1 to a meaningful name.

1 solution

You have two or more source files which contain a class called Class1 in the namespace proto.

The full error message - which you haven't posted - will tell you which files are involved.

Unless you're using partial classes, you can't have the same class in more than one file.

And do yourself a favour and give your classes meaningful names instead of accepting the default name suggested by Visual Studio. Class1 tells you precisely nothing about what the class is for!
 
Share this answer
 
Comments
tsalong tsalong 21-Mar-22 7:37am    
i still have the same error even after creating and naming class to MyClass instate of default one
Richard Deeming 21-Mar-22 7:38am    
So go and look at the files mentioned in the error message!
tsalong tsalong 21-Mar-22 7:38am    
i still have the same error even after creating and naming class to MyClass instate of default one
how do i remove another class
tsalong tsalong 21-Mar-22 7:43am    
Compiler Error Message: CS0433: The type 'proto.MyClass' exists in both 'c:\Users\MPS\AppData\Local\Temp\Temporary ASP.NET Files\vs\a74cd612\1e4f2f\App_Web_muc3bocu.dll' and 'c:\Users\MPS\AppData\Local\Temp\Temporary ASP.NET Files\vs\a74cd612\1e4f2f\assembly\dl3\c3589e35\3192a6ab_153dd801\proto.DLL'
Richard Deeming 21-Mar-22 7:46am    
OK, that's slightly different. It's usually a temporary issue - if you try refreshing the page a few times, it should eventually sort itself out.

If not, you'll need to clear out the c:\Users\MPS\AppData\Local\Temp\Temporary ASP.NET Files\ folder.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900