Class Libraries

J

Jim Heavey

I have a web application which accesses Class Libraries in another project.
Can I add an "App.config" file to my Class Libraries project and be able to
use that configuration information from my web application which has a
reference to the Class Libraries project?

My issue is the connection string to my database. I have been placing it
into the web config file and having my web application read it an pass it
to the class out of the class library....rather then do this, I was wonder
in my Class library to read that information out of it own config file.

You thoughts would be greatly appreciated...


Thanks
 
A

Andy Gaskell

Your class library can read the web.config.

string connectionString =
System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top