Bruce
asked on
Class not found in ASP.NET project
Please forgive me, I'm new to C#.
I have added a class file to my ASP.NET project but I cannot reference it as a type in my default.aspx code behind.
I've put test classes at the root of the project and in folders under App_Code. All the types I try to declare error out on compile.
What steps do I need to take after creating a class file to be able to reference that class in the rest of my app?
I have added a class file to my ASP.NET project but I cannot reference it as a type in my default.aspx code behind.
I've put test classes at the root of the project and in folders under App_Code. All the types I try to declare error out on compile.
What steps do I need to take after creating a class file to be able to reference that class in the rest of my app?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I added the namespace to my class at the root of the project and that gets referenced. But the class that is in my App_Code directory is still not showing. The specific location of the class file I am trying to reference is ~/App_Code/Common/ActiveDi rectoryHel per.cs.
I have tried wrapping these namespaces around the ActiveDirectoryHelper class declaration
AppSurvey_PType
AppSurvey_PType.App_Code
AppSurvey_PType.App_Code.C ommon
After each I tried a rebuild and then tried to dot operate off the AppSurvey_PType namespace but App_Code does not show under there...
Is this where I need to somehow build a DLL for the class file and reference it or can I still try to use namespace to reference it?
I have tried wrapping these namespaces around the ActiveDirectoryHelper class declaration
AppSurvey_PType
AppSurvey_PType.App_Code
AppSurvey_PType.App_Code.C
After each I tried a rebuild and then tried to dot operate off the AppSurvey_PType namespace but App_Code does not show under there...
Is this where I need to somehow build a DLL for the class file and reference it or can I still try to use namespace to reference it?
ASKER
This was a tough one so I just started a new Web Project in Visual Studio. There was something not set right on the "solution" because when I tried to add Web Forms it would not show the options for selecting a master page.
I've added the my existing file from the other project, then added the namespace in those class files and they all show up when I dot operate in the code behind.
Thanks for you help! I don't know what is different between the projects but starting a new one and adding my work back in was the workaround.
I've added the my existing file from the other project, then added the namespace in those class files and they all show up when I dot operate in the code behind.
Thanks for you help! I don't know what is different between the projects but starting a new one and adding my work back in was the workaround.
ASKER
Is this a case of I have to either "Add Reference" to a DLL or wrap the class within a namespace in order to be referenced?
If I do the "Add Reference" on a class that exists only within my project where do I find the DLL on my file structure in order to reference it.