如何在一个解决方案中使用的项目之间共享的资源文件? [英] How to use shared resource file between projects in one solution?

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

问题描述

我有一个资源文件有问题...

I have a problem with resource file...

我有两个项目的解决方案。第一个项目包含 ImageResource.resx 文件与我的图片我所用。每个表格在这个项目可以从设计师访问此文件。但我可以在设计师看到 ImageResource.resx 文件,从第二个项目使用它(的引用第二个项目是present 的)。< BR> 我已经添加了 ImageResource.resx 文件为纽带,以我的第二个项目。我看到它的设计师!但是,当我在第二个项目使用一些图片,从该资源VS修改了原始文件的(它集命名空间,等..)的和我的解决方案brokes。同时VS说我, ImageResource.resx 有present两个dll的 first_project.dll second_project.dll

I have a solution with two projects. The first project contains ImageResource.resx file with my images what I use. Every Form in this project can access to this file from designer. But I can see in the designer ImageResource.resx file to use it from second project (Reference to second project is present).
I've add the ImageResource.resx file as a link to my second project. And I saw it in the designer! But when I use some image from this resource in second project VS modified my original file (It sets the namespaces, and other..) and my solution brokes. Also VS say me that ImageResource.resx has present in two dll's first_project.dll and second_project.dll

Onybody可以帮助我如何正确使用项目之间共享资源?

Onybody can help me How to correctly use shared resource between projects?

谢谢!

推荐答案

在共享一些资源1,正确的方法包括在建立全球共享的项目。新建项目名称为资源;

1.The correct way in sharing some resources consist in creation of the global shared project. Create new Project with name Resources;

2.Next我们必须添加一些资源(如一些图标)到项目中。做到这一点像往常一样。转到项目设置。选择标签资源和添加现有文件......到项目中。我们可以看到,图标添加到项目中,并复制到本地文件夹;

2.Next we must add some resource (e.g some icons) to the project. Do this as usual. Go to the projects setting. Select tab Resources and Add Existing File... to the project. We can see that icon is added to the project and was copied to the local folder;

3.Next步骤包括将这个图标其他项目。但是一个重要的想法!您必须添加该图标的链接。在这种情况下,我们避免了资源的重复。好。新建项目是例如主相同的解决方案和名称。建立在你的其他项目的一些文件夹。例如,我们可以将其命名为资源。 (逻辑名称为我们的目的)。然后右键单击这个文件夹。选择添加现有项...,然后选择我们从共享的项目形象。不要忘了这个文件添加为链接。嗯,你看到刚才添加的文件可以稍微不同的图标;

3.Next step consists of adding this icons to the other project. But one important think! You must add this icon as link. In this case we avoid the resource duplication. OK. Create new Project is same solution and name it for example Main. Create some folder in your other project. For example we can name it as Resource. (Logical name for our purpose). Then right click at this folder. Select Add Existing Item... and choose our image from shared project. Do not forget to add this file as link. Well, you see that just added file can a little differ icon;

添加图像必须看起来像这样

Added image must looks like this

4.Now我们必须设置生成操作这个文件为无。为此,选择该文件,然后转到属性窗口。有选择无的生成操作。我们需要做的是为了避免嵌入该图标大会;

4.Now we must set Build Action for this file to None. For this select the file and go to the Properties Window. There choose None for Build Action. We need to do this to avoid the embedding this icon to the Assembly;

5.Well,我们必须要执行最后一步,完成任务。打开项目设置的项目,我们只是增加了图标。选择资源选项卡,将链接图像的资源。

5.Well, we must to perform last step to complete task. Open Project Settings for project where we just adds the icon. Choose the Resource tab and drag linked image to the resources.

这五个简单的步骤,你必须执行的项目之间共享一些图标。但是,你可以问:这样做有什么好处?主要有:

These five simple steps you must perform to share some icons between projects. But you can ask "What is the benefits of this?" There are:

  • 我们的资源存储在一个地方,很容易更换成新的一些图标。

这篇关于如何在一个解决方案中使用的项目之间共享的资源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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