Problem with app.config from dll

B

Bragadiru

I have a solution with 2 projects: a class library(my.dll) + a windows
application (mine.exe). In exe project I have a reference to the dll. In
both I have app.config files, BUT only mine.exe.config file is generated in
\bin\Debug\ folder of exe app. What can I do to generate my.dll.config from
app.config, too?

Thnx for any advice.
 
N

Nicholas Paldino [.NET/C# MVP]

Bragadiru,

DLL (class libraries) do not have config files. Rather, they share the
configuration information of the EXE that is being used.

What you will have to do is create your own configuration file and read
it appropriately.

Hope this helps.
 
J

Jay B. Harlow [MVP - Outlook]

Bragadiru,
The .Net framework, by default does not use a my.dll.config. Any dll in your
solution will use the mine.exe.config file.

You can 'force' your DLL to use the my.dll.config, by creating a new
AppDomain, setting the AppDomainSetup.ConfigurationFile to 'my.dll.config',
then run the dll in the second AppDomain. Then ensure that the dll runs in
this second AppDomain, while your exe runs in the first AppDomain... There
have been posts in one of the microsoft public dotnet newsgroups on how to
get it to work, I do not have links handy.

Currently I manually add the settings the DLL needs to my 'mine.exe.config'
file and let the dll use those. I use custom configuration sections to
ensure that DLL settings are isolated from exe settings.

These dll configuration sections are defined via:
http://msdn.microsoft.com/library/d...de/html/cpconconfigurationsectionhandlers.asp

and:
http://msdn.microsoft.com/library/d...ref/html/gngrfconfigurationsectionsschema.asp

Eventually I intend on creating a custom
System.Configuration.Install.Installer class that will add the needed
entries to the app.config that the dll needs.

Hope this helps
Jay
 
B

Bragadiru

See MSDN -> Visual Basic and Visual C# Concepts

Walkthrough: Storing and Retrieving Dynamic Properties

"The configuration file in the project folder is named App.config. When you
build the project, it is copied to the output folder and renamed to
Assemblyname.config, where assemblyname is the project output, for example,
MyLibrary.dll or MyApplication.exe. You need to modify this copy of the
..config file to affect a deployed application."


!!??????
 

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