tags:

views:

34

answers:

1

I have a class library(abc.dll) in which i have used a settings file. An exe (app.exe) references this class library. At runtime if i want to change the values of the settings without having to rebuild the class library/application, what is the best way to approach this problem ? In my current approach the setting values get embeded in the library, and thus i dont see any way to update them without rebuilding the whole thing.

A: 

One mechanism involves setting up a configuration file to contain the required information.

Basically, you're looking for the modern equivalent of the old Win16/Win32 .INI files.

.NET supports .config files for this purpose (see the .NET documentation for this).

In my own projects, I've used a mix of .config files and my own XML files. The choice would be up to you.

The tradeoff here is that your application/classlib becomes more complex to support the initialization. The advantage is that if done correctly, you can accomplish significant changes to app/library behavior without requiring a recompile.

kmontgom
You can do this by adding an app.config file to your project in Visual Studio. Watch out though: app.config files for DLL assemblies must be manually loaded.
Damian Powell
Interesting. For some strange reason, I'm not a particular fan of the .config approach. I probably should be, but I like making my own XML config layout.Are there any additional "gotchas" with the .config mechanism?Are there any strong reasons to prefer .config over roll-your-own config?
kmontgom
Manually loading the config as xml and processing it would have been an overkill for my current purpose. So I have fallen back to using the exe's config file.
mishal153