Dela via


Linked and Embedded Resources

Visual Studio projects provide two options for handling resources: they can be linked (the default) or embedded. You can have both linked and embedded resources in a single project. However, most of the time you will want to choose one option for all resources in your project.

Linked resources are stored as files in the project; during compilation the resource data is taken from the files and added to the manifest for the application. The application's resource file (.resx) stores only a relative path or link to the file on disk.

With embedded resources, the resource data is stored directly in the .resx file in a text representation of the binary data. In either case, the resource data is compiled into the executable file.

You can change resources from linked to embedded by changing the Persistence property for the resource file. For more information, see How to: Create Embedded Resources.

Note

String resources are always embedded and cannot be changed; file resources are always linked and cannot be changed.

Choosing Between Embedded and Linked Resources

In general, you should use linked resources because they are easier to use. However, there are cases in which embedded resources might be a better choice.

Embedded Resources

Embedded resources are the best choice if you have to share application resource (.resx) files between multiple projects. For example, if you have a common resource file that contains your company's logos, trademark information, and such, using embedded resources means you have to copy only 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 prompting you to convert the item to a linked resource in order to edit it. Conversion is recommended but optional. You must export them, make your modifications in an external program, and then import them back into your project.

For more information about using embedded resources, see How to: Import or Export Resources and How to: Create Embedded Resources.

Linked Resources

Linked resources (the default) are the best choice for ease of use. Resources can be edited directly inside the project, and you can easily add or remove resources as needed.

See Also

Tasks

How to: Add or Remove Resources

How to: Edit Resources

How to: Create Embedded Resources

How to: Import or Export Resources

Reference

Resources Page, Project Designer

Other Resources

Managing Application Resources