473,566 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class Library reading Web.Config Settings?

Is it possible for me to create a class library DLL and have it read it's
configuration settings from the web.config of the ASP.NET application
referencing it?

IE - if I call ConfigurationSe ttings.GetConfi g("somesection" ) in one of the
base class dll methods, will it/can it return the settings from the
web.config?

For example, I would like to create a base class library of utility classes
that can be used with any ASP.NET application. Per ASP.NET application, you
can configure settings for the base class in the web.config with custom
configuration settings.

Thanks.

TJ
Nov 18 '05 #1
2 2735

"Tony Jones" <to************ ***@hotmail.com > wrote in message news:O4******** ******@TK2MSFTN GP09.phx.gbl...
Is it possible for me to create a class library DLL and have it read it's
configuration settings from the web.config of the ASP.NET application
referencing it?

IE - if I call ConfigurationSe ttings.GetConfi g("somesection" ) in one of the
base class dll methods, will it/can it return the settings from the
web.config?

For example, I would like to create a base class library of utility classes
that can be used with any ASP.NET application. Per ASP.NET application, you
can configure settings for the base class in the web.config with custom
configuration settings.

Thanks.

TJ


Yes, we do it like that. Works perfectly.

Hans Kesting
Nov 18 '05 #2
When you use an external dll in your application this dll will read from the
configuration file of your application when you use
ConfigurationSe ttings.GetConfi g("somesection" ) ( in your case it will read
from the web.config file, because your application is web application )

But if you'll use the same dll in another application it will grab data from
it's configuration file

Regards
Martin

"Tony Jones" <to************ ***@hotmail.com > wrote in message
news:O4******** ******@TK2MSFTN GP09.phx.gbl...
Is it possible for me to create a class library DLL and have it read it's
configuration settings from the web.config of the ASP.NET application
referencing it?

IE - if I call ConfigurationSe ttings.GetConfi g("somesection" ) in one of the base class dll methods, will it/can it return the settings from the
web.config?

For example, I would like to create a base class library of utility classes that can be used with any ASP.NET application. Per ASP.NET application, you can configure settings for the base class in the web.config with custom
configuration settings.

Thanks.

TJ

Nov 18 '05 #3

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

Similar topics

3
2875
by: Florida Coder | last post by:
I have the need to store some application specific configuration data to be used by a class library and or a windows service. I would like to do this in a fashion similar to the way we do with applications and web services without having to use the machine.config file. I know that I could use the code below to do this but the problem...
3
2212
by: grs | last post by:
Can a class library have a app.config file. Reason for asking is that the microsoft application blocks all read from myApp.exe.config. How can you use the application blocks if you do not have an app.config file. Wish someone from microsoft would answer this, I am at a loss. thanks grs
10
1910
by: bradtm | last post by:
So I have this hierarchy: + Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application |
0
1344
by: Chad A. Beckner | last post by:
Hi everyone, I have a common class library (call it common_library) that I include/reference in my projects. In this class library, I would like to have it save certain settings to the user.config for the application. However, when I put in Properties.Settings.Default = somevalue; it kicks back an exception
1
5348
by: Zoe Hart | last post by:
Prior to VS2005 I configured my applications via the appSettings section of the app.config file. When I developed a class library, I used ConfigurationManager.AppSettings(settingName) syntax and the compiler didn't care that no such settings existed yet. The settings were ultimately managed in the app.config file of the host applicaton that...
3
18522
by: Fernando Chilvarguer | last post by:
Hello! I created a Class Library project in VS2005. Then, using VS, I was able to add a connection string to the project settings, which automaticaly created an app.config file for me. If I try to access the configuration using System.Configuration.ConfigurationManager, I get a NullException. The code: string connectionString =
3
2631
by: Martyn Fewtrell | last post by:
Hi there. First of all let me apologise for this is a somewhat general question to which I would be interested in any opinions. As far as I can see when I create a web application the recommended location for the database is the app_data folder. The recommended location for code files and datasets/table adapters appears to be the...
5
8605
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The plan is to delivere different report.dlls with the main app. But it is essentially importent, that the reports and the app use the same settings.
7
10313
by: Peter Bradley | last post by:
OK. A bit behind the times, I know; but we're just moving over to .NET 2.0. How on earth do you manage configuration settings in a class library in .NET 2.0? In version 1.1, we used a handy class called AssemblySettings that someone (I forget his name) had written. When the class library was finished, you deployed it to the GAC and put the...
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.