访问其他项目的app.config属性? [英] Accessing another projects app.config properties?

查看:157
本文介绍了访问其他项目的app.config属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的解决方案中的两个项目,在这个例子中,我会打电话给他们的项目A和B。



项目B引用A.能项目B访问的应用程序。项目A的配置属性?



我想A的的app.config中访问应用程序密钥字符串。

 字符串tfsUri = ConfigurationManager.AppSettings [TfsUri]; 


解决方案

这通常不是一个好主意,因为你介绍硬项目之间的依赖关系。所以,如果你可以复制粘贴配置值,这将使你的项目自包含的(然而,这引入了配置值的重复)。



您也可以自动执行此,这样,当你建立一个项目的配置依赖关系自动解决。



说完,说这个,还有其他的选择,并且在每一种情况下,你可能更愿意使用别的东西。您的其他选项有:




I have two projects within my solution, for this example I will call them project A and B.

Project B references A. Can Project B access the app.config properties of project A?

I wish to access an app key string within the app.config of A.

string tfsUri = ConfigurationManager.AppSettings["TfsUri"];

解决方案

That's generally not a good idea, as you introduce hard dependencies between the projects. So if you can copy-paste config value, that will make your projects self-contained (however, this introduces duplication of config value).

You can also automate this, so that when you build a project the configuration dependency is automatically resolved.

Having-said this, there are other options, and in each case you may prefer to use something else. Your other options are:

这篇关于访问其他项目的app.config属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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