对于整个解决方案共同Settings.settings文件 [英] common Settings.settings file for entire solution

查看:261
本文介绍了对于整个解决方案共同Settings.settings文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法有共同的属性文件解决方案的所有项目?

Is there a way to have common Properties file for all the projects of the solution?

我有其他类librarry文件的控制台应用程序和一堆,我想只生一个设置文件他们。

I have a console application and bunch of other class librarry files and i want to have only one Settings file for them.

我说的不是App.config文件。我说的是Settings.settings文件。

I am not talking about app.Config file. I am talking about Settings.settings file.

任何想法,我可怎么办呢?

Any idea how i can do it?

也是它一个很好的做法存储配置设置在设置文件,而不是app.config中?

Also is it a good practice to store configuration settings in the Settings file rather than app.config?

推荐答案

将您要跨共享的文件在解决方案文件夹项目。然后,在每一个项目,选择添加现有项。

Place the file you want to share across projects in a Solution Folder. Then, in each project, choose to Add Existing Item ..

在添加现有项对话框中,选择常用的文件。相反,单击Add按钮,点击Add按钮右侧的下拉箭头,然后选择添加从下拉菜单链接。

In the Add Existing Item dialog, choose the common file. Instead of clicking the Add button, click the drop-down arrow on the right side of the Add button and choose Add As Link from the drop-down menu.

如果这是一个设置文件,您需要设置该文件的自定义工具属性:

If this is for a Settings file, you need to set the Custom Tool property for the file:

如果您的文件是 Settings.settings 你可以打开你的项目属性,并转到设置选项卡和Visual Studio将自动设置这个自定义工具属性你。

If your file is Settings.settings you can open your project properties and go to the Settings tab and Visual Studio will set this Custom Tool property for you automatically.

在自定义工具设置,你会看到你的设置文件下创建一个文件Designer.cs 。这Designer.cs文件包含生成的代码,以使您的设置编程访问。

Once the Custom Tool is set, you will see a Designer.cs file created underneath your settings file. This Designer.cs file contains generated code to make your settings accessible programatically.

设计师的分档

正如你所看到的,Designer.cs文件也是一个链接文件,它的物理位置将是相同的您的设置文件。

As you can see, the Designer.cs file is also a linked file, and it's physical location will be the same as your settings file.

这篇关于对于整个解决方案共同Settings.settings文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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