访问另一个项目的设置文件 [英] Accessing another project's settings file
问题描述
有从不同的项目访问设置文件的方法吗?例如,我有一个包含2个项目(让我们称之为Proj1和Proj2)的解决方案。我想从Program.cs的访问Proj1 Proj2的应用程序设置。 ?这是可能的。
Is there a way to access the settings file from a different project? For example, I have a solution that contains 2 projects (Lets call them Proj1 and Proj2). I want to access the application settings of Proj2 from Program.cs in Proj1. Is this possible?
推荐答案
选项A:解析值了其他装配的配置文件(存储设置)的
Option A : parse the values out of the other assembly's configuration file (where the settings are stored)
选项b:创建 Proj2
,从它的设置为静态属性暴露必要的值,然后引用一个公共类在 Proj1
组装和使用来自阶级的价值观。
Option B : create a public class in Proj2
that exposes the necessary values from its settings as static properties, then reference the assembly in Proj1
and consume the values from that class.
选项C:如果您希望公开所有设置,您可以修改设置类从内部
到公共
。
Option C : If you want to expose ALL the settings, you can modify the access of the settings class from internal
to public
.
我敢肯定有其他的方式为好。
I'm sure there other ways as well.
这篇关于访问另一个项目的设置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!