471,595 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

Accessing web.config with System.Configuration

I understand what's happening, but not why. I hope somebody else can
help me out.

I wrote a class library - DataAccess. This library can be included in
any type of application but for now is included in an ASP.NET
application. The connection strings for the DataAccess library are
contained in the web.config file but I wrote the library without
including System.Web (because it's not just for Web apps). So I get my
connection strings using System.Configuration.ConfigurationManager, not
System.Web.Configuration.WebConfigurationManager like the ASP.NET
components do. This works. It's fine that it does, but here's what's

If I add an app.config (DataAccess.dll.config) file to DataAccess and
move the connection strings from web.config to DataAccess.dll.config,
the library can't get to them. I still use
System.Configuration.ConfigurationManager but I get a null reference on
the connectionStrings configuration key. Why can my libraries not have
their own configuration files? And why can my library access settings
from the web.config without using the WebConfigurationManager? This
doesn't make sense.

Optimally, I'd want to have DataAccess pull its connection strings from
DataAccess.dll.config unless they've been overridden by the hosting
application's settings. So the library could then be a plug & play
component and the developer writing an application that includes
DataAccess could override any configuration settings by including them
in the app.config or web.config for his/her application, while leaving
the DataAccess.dll.config file untouched.

Nov 22 '06 #1
0 1228

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by runningdog | last post: by
1 post views Thread by Dan Noel | last post: by
reply views Thread by Andrzej Kaczmarczyk | last post: by
8 posts views Thread by Alberto | last post: by
reply views Thread by jordonkraft | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.