I have a problem with resource files.
I have a solution with two projects. The first project contains ImageResource.resx
file with the images that I use. Every Form
in this project can access this file from the designer. But I can see in the designer ImageResource.resx
file to use it from second project (Reference to second project is present).
I have added the ImageResource.resx
file as a link to my second project. And I saw it in the designer! But when I use an image from this resource in the second project Visual Studio modified my original file (It sets the namespaces, and other..) and my solution breaks. Also Visual Studio tells me that ImageResource.resx
is present in two dll's first_project.dll
and second_project.dll
Can anybody help me with How to correctly use shared resources between projects?
Next step consists of adding this icon to the other project(s). Note the important difference, you need to add this icon as a link!
Adding as a link avoids the resource duplication. Create a new Project within the same solution and name it e.g. Main. Create some folder in this new project, naming it Resources (the logical name for our purpose). Then right click on this folder, select Add Existing Item… and choose the image file from the shared project folder. Make sure to use Add As Link here! If done correctly the icon of the newly added file will look slightly different (see below):
Added resource's icon must look like this
These are the five simple steps you must perform to share icons between projects. You might ask "What are the benefits of this?" The benefits are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With