473,385 Members | 1,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,385 software developers and data experts.

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.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
Nov 16 '05 #1
3 2205
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.com

"grs" <gs****@budgetext.com> wrote in message
news:O5**************@TK2MSFTNGP14.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.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

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.com> wrote in
message news:ew**************@TK2MSFTNGP09.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.com

"grs" <gs****@budgetext.com> wrote in message
news:O5**************@TK2MSFTNGP14.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.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


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.bet 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
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...
3
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...
12
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...
1
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...
10
by: bradtm | last post by:
So I have this hierarchy: + Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application |
3
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...
3
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...
0
by: metaperl | last post by:
A Comparison of Python Class Objects and Init Files for Program Configuration ============================================================================= Terrence Brannon bauhaus@metaperl.com...
7
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...
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: 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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.