By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,914 Members | 1,716 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,914 IT Pros & Developers. It's quick & easy.

class libraries - app.config

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.