/linkresource (Link to .NET Framework Resource)
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

/linkresource (Link to .NET Framework Resource)



The .NET Framework resource file to which you want to link from the assembly.
identifier (optional)
The logical name for the resource; the name used to load the resource. The default is the name of the file name.


The /linkresource option creates a link to a .NET Framework resource in the output file; the resource file is not placed in the output file. /resource embeds a resource file in the output file.

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

/linkresource requires one of the /target options other than /target:module.

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.

The file specified in filename can be any format. For example, you may want to make a native DLL part of the assembly, so it can be installed into the Global Assembly Cache and accessed from managed code in the assembly.

/linkres is the short form of /linkresource.

To set this compiler option in the Visual Studio development environment

This compiler option is unavailable in Visual Studio.

To set this compiler option programmatically

This compiler option cannot be changed programmatically.


Compile in.cs and link to resource file rf.resource:

csc /linkresource:rf.resource in.cs

See Also

C# Compiler Options

© 2016 Microsoft