473,372 Members | 925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 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 1310

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Erick | last post by:
Hi, I have a Installer class used to install my windows service, it was created by the wizard that is in the VS, I just whent into the properties and set up the properties of the ServiceInstaller...
by: runningdog | last post by:
HI, Sorry if this is a bit long winded I'm working on a suite of winapps that need to use two levels of configuration data; application level and solution level. I found a reference on MSDN...
by: Dan Noel | last post by:
I see many rich classes in System.Configuration, but all of these classes are read-only. While I have many rich classes for extracting information from a config while, I am reduced to the most...
by: Andrzej Kaczmarczyk | last post by:
Hello, I am having troubles saving configuration file. I did the folloing: inherited from ConfigurationSection, ConfigurationCollection, ConfigurationElement to define my own element in...
by: phillip | last post by:
This is interesting, I have attached my web.config file and the exception I have been logging. I created a library which provide data access to a database and a control system. The library is...
by: stephen | last post by:
Hi all, I am getting this error: An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in system.web.dll Additional information: Exception creating section...
by: Alberto | last post by:
Can you tell me how to read and modify a value in the app.config file using this class? Thank you very much
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
by: jordonkraft | last post by:
Hello, I have been searching the net, MSDN, google groups and can't seem to find anything about what is happening to me. I have developed a application using VB.Net 2.0 and deploy it using...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.