Could i access ConnectionStringSettingsCollection ( Web.Config ) in Class Library?

S

Serdge Kooleman

Could i access Web.Config in Class Library?

Next line work fine in web project that consist Web.config:

strConnString =
System.Web.Configuration.WebConfigurationManager.ConnectionStrings["CONN"].ConnectionString;

but when i call it from class library it give an error:

The type 'System.Configuration.ConnectionStringSettingsCollection' is
defined in an assembly that is not referenced. You must add a reference to
assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'. C:\Inetpub\wwwroot\Ra\RaLib\RaLib\cDB.cs
26 13 RaLib


Thank you
 
M

Marc Gravell

Yes, you an (in fact, behind the scenes your aspnet pages *become* a
library (dll)) - you just need to follow the instruction it gives you
and add a reference to System.Web

Marc
 

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