What is the difference between a resource and an embedded resource in a C # application?

When should I use one or the other?

I would like all the files that I use in my application (images, sound, xml file, etc.) to be inside the .exe file, so I do not deploy with several folders and files.

Thanks for the information.

+73
c # resources wpf embedded-resource
Dec 20 '09 at 4:18
source share
4 answers

Resource and content creation steps are for accessing WPF resources using Uris. However, the Embedded Resource is for previous technologies. However, both parameters include the resource in the assembly, but the Resource parameter will be used for WPF.

MSDN gives a full explanation here .

+67
Dec 20 '09 at 6:26
source share

The WPF resource (build action = Resource) uses the embedded resources supported by the underlying .NET platform, but adds support for accessing the embedded resource through the package URI . From MSDN :

WPF resource files are different from the built-in or related resource types that you can configure using the .NET Framework basic support for assembly resources. While WPF resource files do support basic support for the built-in .NET Framework resources, accessing WPF resource files using URI packages is easier than using namespaces.

+7
Dec 20 '09 at 12:29
source share

According to MSDN,

Nested resources are the best choice if you need to share a resource application (.resx) between several projects. For example, if you have a shared resource file that contains your company logos, trademark information, etc., using the built-in resources means that you should only copy the .resx file and not the associated resource data files.

You cannot edit embedded resources directly. If you try to edit an embedded resource, you will receive a message asking you to convert to a related resource in order to edit it. Recommended to convert, but optional. You must export them, make your changes in an external program, and then import them back into your project.

+3
Dec 20 '09 at 4:28
source share

Thank you for all the reports that helped me more accurately find out where the problem was: For me, these were images that were used as the project icon on the taskbar, which was created as resources and had to be built as content. All other images can be created as resources, without any problems.

Hope this helps in the future.

0
Feb 12 '13 at 11:25
source share



All Articles