开发者

Associating a modifyable settings file with a class library in C#?

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, 开发者_JS百科and thus i dont see any way to update them without rebuilding the whole thing.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜