Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dll with service reference should read custom configfile

Tags:

c#

I have a problem using a dll with a service reference that should read a custom configfile.

My situation is as follows: - DLL which read its own config file (by using configurationManager.openExeConfiguration(dllname.dll.config)) - main application which uses the DLL (3d-party application)

This is working fine, the dll reads the right configsettings.

Now I must add a service-reference to my DLL. The problem is that it tries to read the standard app.config file (which doesn't exist), instead of reading the dllname.dll.config file.

Anyone has a solution for this?

Thanks,

like image 407
Mattew Avatar asked Nov 05 '22 18:11

Mattew


1 Answers

In .NET, it has never been the intention that libraries should have their own .config files, so there's no official support of this and lots of issues are sure to abound.

Although you can read such a file with ConfigurationManager.OpenExeConfiguration, this was never the intention of that API - it's mainly there to provide an API for editing application .config files.

You would be much better off if you let the library read from the app.config file instead, using the standard ConfigurationManager API. You can still have custom sections for your library in the app.config file. This is the way it was always intended to work, and it will give you far less trouble.

like image 140
Mark Seemann Avatar answered Nov 14 '22 21:11

Mark Seemann