使用的app.config一个类库类库、app、config

由网友(让你失望了)分享简介:我经常需要创建一个.NET类库,需要一个app.config的东西,如数据库连接字符串。但是,这些设置必须在调用应用程序的的app.config或web.config中。如果我要分发在多个应用程序就变成了DLL一个痛苦保持应用程序的App.config中复制这些设置。Frequently I need to crea...

我经常需要创建一个.NET类库,需要一个app.config的东西,如数据库连接字符串。但是,这些设置必须在调用应用程序的的app.config或web.config中。如果我要分发在多个应用程序就变成了DLL一个痛苦保持应用程序的App.config中复制这些设置。

Frequently I need to create a .Net class library that requires an app.config for things such as database connection strings. However, these settings must be in the calling application's app.config or web.config. If I want to distribute the DLL across multiple applications it becomes a pain to have to keep copying these settings in the application's app.config.

我已经手动考虑读通过类库里面code的配置设置,但是这也是一个重大的痛苦。没有人有任何建议的最佳方式来加载的app.config设置里面一个类库?

I have considered manually reading the config settings via code inside the class library, but that is also a major pain. Does anyone have any suggestions for the best way to load app.config settings inside a class library?

推荐答案

有一件事情你可以做的是有一个单独的设置文件只为您的图书馆,那么你只需要拥有一提到它在您的输入应用程序的配置文件

One thing you could do is to have a seperate settings file just for your library, then you only have to have a reference to it in your entry apps config file.

见accepted在这个问题了解这些信息。

See the accepted answer in this question for information on this.

阅读全文

相关推荐

最新文章