.Net 2.0 app.config / deployment

G

Guest

Hello
I created a dll assembly unsing the settings (only application settings). I
read a lot a lot about the new settings concept, but I still don't understand
it.

The settings are in two places. First in the settings file which can be
edited a gui, second in the app.config file which is used in the development
enviornment. So far so good... but...

When I deploy my application and have a <dll filename>.config file in the
same directory where my dll file is, it does not work when I change settings
in the .config file. It always uses the default settings which are still from
the development enviornment.

How can I make my dll use the settings from the .config file and not the
default settings?

Help you very much,
Peter
 
N

Nicholas Paldino [.NET/C# MVP]

Peter,

When you have a config file, you need to place your settings in the
config file for the executable. Libraries could not (and should not, IMO)
have a config file of their own, since they are working in the larger
context of the application that references them.

Hope this helps.
 
A

Andy

Peter,

Try:

Configuration = ConfigurationManager.OpenExeConfiguration(
Assembly.GetExecutingAssembly().Location );

HTH
Andy
 
G

Guest

That's an interesting point. I am trying to store configuration information
for a data layer library that needs to be configured to access different
databases/servers, with stored userId and password, etc. How can I do this
for such 'behind the scenes' library classes without using a different config
file for each different project/module that calls the data access classes?

Should I be using machine.config or something?

Thanks

Ian

Nicholas Paldino said:
Peter,

When you have a config file, you need to place your settings in the
config file for the executable. Libraries could not (and should not, IMO)
have a config file of their own, since they are working in the larger
context of the application that references them.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Peter said:
Hello
I created a dll assembly unsing the settings (only application settings).
I
read a lot a lot about the new settings concept, but I still don't
understand
it.

The settings are in two places. First in the settings file which can be
edited a gui, second in the app.config file which is used in the
development
enviornment. So far so good... but...

When I deploy my application and have a <dll filename>.config file in the
same directory where my dll file is, it does not work when I change
settings
in the .config file. It always uses the default settings which are still
from
the development enviornment.

How can I make my dll use the settings from the .config file and not the
default settings?

Help you very much,
Peter
 
N

Nicholas Paldino [.NET/C# MVP]

Ian,

You could use machine.config, and that will set the "default" for that
machine, should there be no section in the application configuration file.
Those settings will always override the machine.config settings.

If you have your application libraries being used in many different
areas, and you want to set the defaults through a config file, then
machine.config is a good way to do it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Ian said:
That's an interesting point. I am trying to store configuration
information
for a data layer library that needs to be configured to access different
databases/servers, with stored userId and password, etc. How can I do this
for such 'behind the scenes' library classes without using a different
config
file for each different project/module that calls the data access classes?

Should I be using machine.config or something?

Thanks

Ian

Nicholas Paldino said:
Peter,

When you have a config file, you need to place your settings in the
config file for the executable. Libraries could not (and should not,
IMO)
have a config file of their own, since they are working in the larger
context of the application that references them.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Peter said:
Hello
I created a dll assembly unsing the settings (only application
settings).
I
read a lot a lot about the new settings concept, but I still don't
understand
it.

The settings are in two places. First in the settings file which can be
edited a gui, second in the app.config file which is used in the
development
enviornment. So far so good... but...

When I deploy my application and have a <dll filename>.config file in
the
same directory where my dll file is, it does not work when I change
settings
in the .config file. It always uses the default settings which are
still
from
the development enviornment.

How can I make my dll use the settings from the .config file and not
the
default settings?

Help you very much,
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top