473,387 Members | 1,588 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,387 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
confusing:

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 1312

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

Similar topics

0
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...
0
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...
1
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...
0
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...
0
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...
0
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...
8
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
3
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...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.