如何在多个项目之间共享应用程序配置文件 [英] How to share app config files between multiple projects

查看:156
本文介绍了如何在多个项目之间共享应用程序配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个项目



Project1(窗口项目)



Project2(wpf项目)< br $>


Project3(wpf项目)



Project4(图书馆计划)



都有自己的应用程序配置文件,



i希望在多个项目中使用单个应用程序配置



我该怎么办呢



i试图将app配置文件添加到解决方案中但是没有选项添加应用程序配置文件



或者最小值只有一个连接字符串的位置。

i have 4 projects

Project1(window project)

Project2(wpf project)

Project3(wpf project)

Project4(library Project)

all have own app config file,

i want to use single app config along multiple projects

how can i do thatt

i have tried to add app config file into solutions but there is no option to add application configuration file

or minimum have a single location for the connection string.

推荐答案

在我看来项目2,3和4不是独立的应用程序。我不会将应用程序配置文件分配给这样的库项目。我会编写这些应用程序,以便他们拥有构建器,其中包含应用程序配置文件所需的所有内容。然后调用项目(Project1)将使用这些构造函数创建对象。因此,Project1是唯一需要app配置文件的项目。
It looks to me that projects 2,3 & 4 are not standalone apps. I would not assign an app config file to a library project like that. I would write those apps such that they have constructors with everything they would need from the app config files. Then the calling project (Project1) would create the objects with those constructors. Thus, Project1 is the only project that needs an app config file.


如果你真的想这样做,请看看:

MSBuild复制任务 [ ^ ]



祝你好运

Espen Harlinn
If you really want to do that, take a look at:
MSBuild Copy Task[^]

Best regards
Espen Harlinn


如果你真的想这样做(我不确定,请看Roy的答案),原则上有一种方法。



对于一个项目,请执行:[Solution Explorer]:Add=> 添加新项目=> 一般=> 应用程序配置文件。



对于其他项目,请按以下方式使用同一文件:

[解决方案资源管理器]:添加=> 添加现有项目=>

[在文件对话框中:选择相同的文件=> 添加(小向右箭头)=> 添加为链接]



这里的关键是添加为链接。您将只有一个物理文件,链接到同一解决方案的多个项目。



-SA
If you really want to do this (which I'm not sure, see the answer by Roy), there is a way, in principle.

For one project, do: [Solution Explorer]: "Add" => "Add New Item" => "General" => "Application Configuration file".

For other projects, use the same file in the following way:
[Solution Explorer]: "Add" => "Add Existing Item" =>
[In file dialog box: select the same file => "Add" (small right down arrow) => "Add As Link" ]

The key here is "Add As Link". You will have only one physical file, linked to more than one project of the same solution.

—SA


这篇关于如何在多个项目之间共享应用程序配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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