473,666 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

class libraries - app.config

grs
Can a class library have a app.config file. Reason for asking is that the
microsoft application blocks all read from myApp.exe.confi g. 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
Nov 16 '05 #1
3 2218
grs,

I'm not from MS, but I can tell you definitely that a library can not
have it's own application configuration section. The config file is to have
a single place to modify all aspects of the application. If you were able
to change these settings somewhere else, then you are basically going
against the wishes of the user of the client executable, and that generally
is a no no. You should create a custom configuration section in your
app.config file, and have your library read the settings from there (most
libraries in the framework do this already).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"grs" <gs****@budgete xt.com> wrote in message
news:O5******** ******@TK2MSFTN GP14.phx.gbl...
Can a class library have a app.config file. Reason for asking is that the
microsoft application blocks all read from myApp.exe.confi g. 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

Nov 16 '05 #2
grs
thanks for reply Nicholas. My problem is that I am not in control of the
application that creates the config file but I am writing a library that
will be accessed by the program that is the "enterprise exe". It seems
totally wrong that we can not use the application blocks in a library
(unless we modify the source of the application blocks).

Any suggestions would be welcome.
grs
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:ew******** ******@TK2MSFTN GP09.phx.gbl...
grs,

I'm not from MS, but I can tell you definitely that a library can not
have it's own application configuration section. The config file is to have a single place to modify all aspects of the application. If you were able to change these settings somewhere else, then you are basically going
against the wishes of the user of the client executable, and that generally is a no no. You should create a custom configuration section in your
app.config file, and have your library read the settings from there (most
libraries in the framework do this already).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"grs" <gs****@budgete xt.com> wrote in message
news:O5******** ******@TK2MSFTN GP14.phx.gbl...
Can a class library have a app.config file. Reason for asking is that the microsoft application blocks all read from myApp.exe.confi g. 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


Nov 16 '05 #3
grs wrote:
thanks for reply Nicholas. My problem is that I am not in control of
the application that creates the config file but I am writing a
library that will be accessed by the program that is the "enterprise
exe". It seems totally wrong that we can not use the application
blocks in a library (unless we modify the source of the application
blocks).


As Nicholas says, a config file is associated with a process assembly not a
library. My FAQ on configuration addresses some of the issues:

http://www.grimes.demon.co.uk/dotnet/configFAQ.htm

For system objects the configuration will always be read from the app config
file, this is a *good* idea because it makes the settings global to the
application. However, if you simply want to provide settings for your own
classes, then you don't need to put those in the configuratiojn file at all.
Instead you can use a custom configuration scheme by defining your own
configuration object and deserialing it from disk when you want the settings
and serializing it to disk when you want to change a persisted setting.
There are several ways in .NET to do this, and I mention some of the options
in my FAQ.

Richard
--
www.richardgrimes.com
my email ev******@zicf.b et is encrypted with ROT13 (www.rot13.org)
Nov 16 '05 #4

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

Similar topics

0
1347
by: Mattias | last post by:
Hi, I want to use the CMAB to retrieve configuration details for a class library. More particular, I'm developping a Data Access Layer in class libraries, with later on BL, allowing any application (as a Presentation Layer) to access the business logic of the class library. I'd like to store essential configuration details (connection strings, environement settings) in the machine.config file, allowing the DEV/TEST/PROD system only to...
3
2879
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 then becomes that when using a shared assembly both the assembly and the config file need to be put...
12
2253
by: CodeRazor | last post by:
Hi, I am building a class library and want to store a connection string in a configuration file. I've read around and it appears that this is not possible because "by design, class libraries don't have their own config file - they read the config files from the application they are housed in, such as a WinForm app or ASP.NET site "
1
258
by: Jim Heavey | last post by:
I have a web application which accesses Class Libraries in another project. Can I add an "App.config" file to my Class Libraries project and be able to use that configuration information from my web application which has a reference to the Class Libraries project? My issue is the connection string to my database. I have been placing it into the web config file and having my web application read it an pass it to the class out of the...
10
1916
by: bradtm | last post by:
So I have this hierarchy: + Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application |
3
3938
by: ad | last post by:
I have a web application and a class library in a solution. The class library is make of typed datasets, and include many Table in it. The connection strings of the TableAdapters is come from the app.config of that class library. The Web application refer the class library, and the connection strings of WebApp is come from the web.config of it. It is ok in developing step, I can make both connection string identical in
3
18525
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 =
0
2499
by: metaperl | last post by:
A Comparison of Python Class Objects and Init Files for Program Configuration ============================================================================= Terrence Brannon bauhaus@metaperl.com http://www.livingcosmos.org/Members/sundevil/python/articles/a-comparison-of-python-class-objects-and-init-files-for-program-configuration/view
7
10318
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 configuration files in the GAC with the class library assembly. This no longer works. In fact...
0
8440
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8866
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6191
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5662
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
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
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.