.NET Class Libraries: Application Settings, Config-File October 23, 2011at14:53

I’m getting to a point where my programming limitations (skill-wise) is in the subtleties of different languages and platforms rather than general concepts, algorithms and design. It is a nice feeling to feel proficient in what you do, but oh so frustrating when you stumble on the small exceptions and querks in a langue or platform. This weekend it was C# and .NET Class Libraries. Apparently, class libraries ignore the LIB.dll.config file. It retains the default values it was compiled with, no matter what you write in the file, or if it’s even there. Very frustrating when you writing a plug-in architecture with configurable plug-ins. Not to mention all the time spent trying to figure out why the damn plug-in wouldn’t accept my changes in the config file.

So now you know! The application settings model does not work with Class Libraries. You can still use them in design time, but once you ship, the content of the config file will not matter. If you want your class libraries to be configurable, you have to roll your own. I’m suggesting reading and parsing the application config file, since it is there anyway -just do it your self. If I bother to do it myself for my application, I’ll try to write a general wrapper class and publish it here.

Comments are closed.