/resource (Embed Resource File to Output)
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

/resource (Embed Resource File to Output)



The .NET Framework resource file you want to embed in the output file.
identifier (optional)
The logical name for the resource; the name used to load the resource. The default is the name of the file name.


Use /linkresource to link a resource to an assembly and not place the resource file in the output file.

Resources are public in the assembly when created with the C# compiler.

If filename is a .NET Framework resource file created, for example, by Resgen.exe or in the development environment, it can be accessed with members in the System.Resources namespace (see System.Resources.ResourceManager for more information). For all other resources, use the GetManifestResource* methods in the System.Reflection.Assembly class to access the resource at run time.

/res is the short form of /resource.

To set this compiler option in the Visual Studio development environment

  1. Add a resource file to your project.
  2. Select the file you want to embed in Solution Explorer.
  3. Select Build Action for the file in the Properties window.
  4. Set Build Action to Embedded Resource.

To set this compiler option programmatically

See BuildAction Property (Visual Basic and C# ProjectItem Object).


Compile in.cs and attach resource file rf.resource:

csc /resource:rf.resource in.cs

See Also

C# Compiler Options

© 2016 Microsoft