如何访问从我的类库的应用程序自定义的配置? [英] How to access a custom config from my class library application?

查看:148
本文介绍了如何访问从我的类库的应用程序自定义的配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的配置在我的基础设施项目,但是当我的应用程序才开始我的web.config是公认的。

I have a custom config in my Infrastructure Project, but when my app start only my web.config is recognized.

我不想把我的web.config此自定义配置文件的配置,因为这种配置是基础设施层责任。

I don't want to place the configuration of this custom config file in my web.config because this configuration is responsability for Infrastructure Layer.

我如何使用从其他项目这个自定义的配置在我的web项目?

How I use this custom config from another project in my web project?

推荐答案

在previous这个问题的答案是没有通知的关键点你。

The previous answers to this question are failing to inform you of a critical point.

.NET的设计有一个单独的配置过程的每个的AppDomain 。所有的类库将使用它调用它们的应用程序的配置文件。在你的情况,你的类库将使用web.config中。如果您的类库,正在从一个控制台应用程序使用,那么它将使用的应用程序的.exe.config文件与。

.NET is designed to have a single configuration process for each AppDomain. All class libraries will use the configuration file of the application which calls them. In your case, your class library will use the web.config. If your class library were being used from a console application, then it would use the application.exe.config file.

当你想想看,这是唯一有意义的事情。如果你的类库是从两个独立的应用中,那么它将具有两个单独的配置。这些配置的必须的代表调用应用程序的管理。

When you think about it, this is the only thing that makes sense. If your class library is used from two separate applications, then it will have two separate configurations. These configurations must be managed on behalf of the calling application.

这篇关于如何访问从我的类库的应用程序自定义的配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆