Visual Studio: How to store an image resource as an Embedded Resource?

Note: This answer is not the recommended way of handling image resources. It just addresses the particular problem as described by the question (i.e. to include an image as an embedded resourse).

Don’t add the image as a resource. I would rather do the following:

  • Create the image/icon and save it to a file
  • Choose Project -> Add Existing Item and add the file
  • Set the Build Action to Embedded Resource

You can then access this resource using

Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceUri)

This way the image is not magically added to the projects resource file and you will only have one copy of the image stored in the assembly’s resources.

Leave a Comment