Deployment nightmares with app.config

K

Keith Elder

Let's say you have a stand alone C# library project that is your
datalayer. When this library compiles it will produce
"My.DataLayer.dll" for example.

In the project you use all the new whizbang DataSet generation tools to
create some datasets, etc in your DataLayer project. When you setup a
connection string it adds a settings.settings file and na app.config to
the project which holds the connection string. Essentially the
settings.settings is a front-end to the app.config file.

Now, you compile your project and everything works, except the
app.config file is embedded into your DLL. This means you cannot take
the DLL and copy it to production or beta without first changing the
settings and regenerating the app.config and recompiling.

I read somewhere a long time ago that you can rename the app.config file
to the My.DataLayer.dll.config for example but it doesn't appear to
pickup the settings in the new config file, they are STILL embedded
within the DLL (even though the file is set to not copy and not embed).

Anyone know of a way around this?

-Keith
 
K

Keith Elder

That defeats the purpose of deploying a stand alone DLL though. It
should rely on some other file in another project. Plus doing that
removes the connection string from the designer.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

A config file exist only for an executable, a DLL has no config associated.
You have a couple of options though ( I listed them in a decreasing
priority list)

1- Create an Init method for the dll
2- Create a config file only for the dll and place it in the same folder
than the dll, you can read it later and interprete the config options.
3- Create a config section in the .exe config file, the dll can read its
values from there. and they do not interfere with other dlls/ the exe
settings.
 

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