Image creation steps: difference between None and embedded resource?

I use images above some of my buttons, and I don't want these images to be included in the output.

These images are set using the button properties, so they are defined in the Resource.resx file.

I was told to install Build Action for Embedded Resource, but I am curious why this matters. I have a build action set to No right now and none of the files are set to copy. And I can move the embedded application anywhere and run it, and all the images are displayed just fine. (To clarify, the images are certainly not in the program directory when it starts, and they still look just fine).

I looked it up on MSDN and got the following:

Not. The file is not included in the project output group and is not compiled during the build process. An example is a text file containing documentation, such as a Readme file.

Nested resource - this file is embedded in the main data collection of the project as a DLL or executable file. This is commonly used for resource files.

But because of this, it sounds like they are all installed on None, they shouldn't even work (but it does).

So, I'm curious about the benefits that this provides with Embedded Resource. I checked it, and there was no difference. I wanted someone to explain what was happening.

My only assumption is that when setting the image property using the button, and the record is added to the resource file, it is in no way associated with the file added to the project (although they are the same). Therefore, if you set the image property this way, the images should not even be included in the project (i.e., in the solution explorer).

Thanks!

+7
source share
1 answer

You seem to have stumbled upon two different ways of displaying an image.

  • If you use a resource file, the resource file itself will contain images, and this file will be copied to the output directory. You will then be referenced by an image from this resource file, and everything will be Well. Actual image setup for none / embedded / content will not matter. This allows you to create resource files for different languages ​​and locations and change which image is used based on your application culture.

  • Another way to link to an image is either by embedding it, or by setting it as content in a project. If you set it as content, it will be copied to the output directory and may be physically based on the location, or if you paste it, the file will be inside the created dll, and you can pull out the resource stream with this file in it using the built-in functions.

You use method # 1, therefore, as soon as you put it in a resource file that you do not need to have in the project, since the resource file is already in the project, and that is where the file will be created.

+8
source

All Articles