开发者

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

开发者 https://www.devze.com 2022-12-27 15:17 出处:网络
I have a class library(abc.dll) in which i have used a settings file. An exe (app.exe) referencesthis class library. At runtime if i want to change the values of the settings without having to rebuild

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

精彩评论

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

关注公众号