Answered by:
accessing class file outside App_Code folder

Question
-
User1281245994 posted
Hi, I have a single project. and I have two folder in it. In the 1st folder I have a class named Class1 and in the 2nd folder I have a class named Class2. Can anyone tell me how I can access members of Class1 in Class2. I have tried by adding namespace in Class1 and Using that namespace in Class2. But it is giving error. It is easy to access classes or their members from App_Code folder. I don't want to put my classes in app_code folder. Thanks in Advance
Tuesday, April 27, 2010 2:45 PM
Answers
-
User533502567 posted
Hi, I have a single project. and I have two folder in it. In the 1st folder I have a class named Class1 and in the 2nd folder I have a class named Class2. Can anyone tell me how I can access members of Class1 in Class2.Refer this..
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 27, 2010 2:54 PM -
User551462331 posted
only classes present in app_code folder of application can be consumed directly by the pages in that app.
if u want to use classes which u dont want to put in app_code,
then create separate class library project of those class file and create a dll of those classes.
add reference to this dll in u r web app. and then u can access methods of those classes in u r web app.
hope this helps...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 27, 2010 4:22 PM -
User-48124152 posted
hi,
You can compile the class into an assembly (dll) and place the dll in the bin folder.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 27, 2010 8:03 PM
All replies
-
User533502567 posted
Hi, I have a single project. and I have two folder in it. In the 1st folder I have a class named Class1 and in the 2nd folder I have a class named Class2. Can anyone tell me how I can access members of Class1 in Class2.Refer this..
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 27, 2010 2:54 PM -
User-304147557 posted
The App_Code folder is mainly used with Website projects whereas with Web Application Projects you would typically reference the library class.you should either use the Web Application Project or to put your code into a DLL and then reference it.http://blogs.msdn.com/asgoyal/archive/2009/06/16/consuming-a-class-which-is-outside-of-app-code-folder-in-an-asp-net-website-project.aspxhttp://www.velocityreviews.com/forums/t556894-how-to-create-object-of-a-class-which-is-outside-of-appcode-folderin-aspnet-20-using-c.html
Tuesday, April 27, 2010 2:56 PM -
User551462331 posted
only classes present in app_code folder of application can be consumed directly by the pages in that app.
if u want to use classes which u dont want to put in app_code,
then create separate class library project of those class file and create a dll of those classes.
add reference to this dll in u r web app. and then u can access methods of those classes in u r web app.
hope this helps...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 27, 2010 4:22 PM -
User-1199946673 posted
I don't want to put my classes in app_code folder.Why not? Where do you want to put them and what's the advantage of that?
Tuesday, April 27, 2010 7:09 PM -
User-48124152 posted
hi,
You can compile the class into an assembly (dll) and place the dll in the bin folder.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 27, 2010 8:03 PM