如何从一个.dll访问应用程序的配置?应用程序、dll

由网友(治愈系男神经i)分享简介:我最近打破了我的winform应用程序中的一个.dll的一部分。一些班级在该DLL想获取/存储用户设置。这些类只是用VS生成的设置文件,所以它只是做了Properties.Settings.Default.SomeSetting =变种; Properties.Settings.Default.Save()等I...

我最近打破了我的winform应用程序中的一个.dll的一部分。一些班级在该DLL 想获取/存储用户设置。 这些类只是用VS生成的设置文件,所以它只是做了 Properties.Settings.Default.SomeSetting =变种; Properties.Settings.Default.Save()

I recently broke out a part of my winform app in a .dll. Some of the classes in that dll wants fetch/store user settings. The classes just used the VS generated Settings file so it just did Properties.Settings.Default.SomeSetting = var;Properties.Settings.Default.Save() etc.

什么是我的选择,现在我感动的是code出一个类库/ .DLL?

What are my options now that I moved that code out to a class library/.dll ?

推荐答案

的托管应用程序应该处理的接口配置文件,而不是DLL。无论是

The hosting application should handle the interface to the config file, not the DLL. Either

传递任何需要读取/在DLL中修改参数设置,或

Pass whatever settings need to be read/modified within the DLL as parameters, or

传入的设置,可以由DLL被修饰,一个名称 - 值集合和任何变化由该DLL作出保存到集合时控制返回到调用应用程序

Pass in a name-value collection of settings that can be modified by the DLL, and save whatever changes are made by the DLL to the collection when control returns to the calling application.

这在原则上是从一个分层应用程序的业务层移除数据库接口,并将其封装到一个数据层相似。

This is similar in principle to removing a database interface from the business layer of a tiered application and encapsulating it into a data layer.

阅读全文

相关推荐

最新文章