Click here to Skip to main content
16,017,373 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
I have created a project called DAL with Class file for accessing data and another web application project (inside same sln file)to consume the above mentioned class project. my class project needs to take connection string from config file and then establish the connection.

i add a reference on my class project file to my application project file and added

"using System.Data.SqlClient;
using System.Configuration; "

still im unable to access my class file inside my application project. Can you please see what else is missing?

should i add reference from class to application or is it the other way??
Posted
Comments
Sergey Alexandrovich Kryukov 31-May-11 12:45pm    
What do you mean unable?
--SA

They name spaces you show probably has nothing to do with your own project you reference. Did you put your own class under one of these name spaces? If not, these uses clauses are irrelevant.

When you add your .NET library to your other project, double click your reference on the Solution Explorer tree. You will be able to browse reflected referenced assembly. Do you see your class and its members you want to use? If not, check up if you use public access specifier for each type and member you need to make accessible to referencing assembly. When all declarations you need are available, use your declarations with fully-qualified names including their name space names. Or add using declarations, appropriate ones.

—SA
 
Share this answer
 
Comments
Torontouser 31-May-11 13:12pm    
Found it..

So have to add reference to from my application file to class file + add using name space along with reference.

for my class file to access config data ...just added another reference to system.configuration fiile...
Sergey Alexandrovich Kryukov 31-May-11 13:51pm    
Good. Thanks for accepting this answer.
Good luck,
--SA
You need to be adding a class project reference to the application project.
Also, make sure your class is public and not internal.
 
Share this answer
 
Comments
Torontouser 31-May-11 13:02pm    
i did add a reference on my application project to the class project.and it is public. is there anything else i need to do. when i type my class name on my aspx.cs file it should be showing the class name on intellisence....isn't it the right way.

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