Creates a link to a .NET Framework resource in the output file. The resource file is not added to the output file. This differs from The -resource option which does embed a resource file in the output file.
-linkresource:filename[,identifier[,accessibility-modifier]]
filename | The .NET Framework resource file to which you want to link from the assembly. |
identifier (optional) | The logical name for the resource; the name that is used to load the resource. The default is the name of the file. |
accessibility-modifier
(optional) | The accessibility of the resource: public or private. The default is public. |
By default, linked resources are public in the assembly when they are created with the X# compiler. To make the resources private, specify private as the accessibility modifier. No other modifier other than public or private is allowed.
-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. For more information, see System.Resources.ResourceManager. For all other resources, use the GetManifestResource* methods in the 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 that it can be installed into the global assembly cache and accessed from managed code in the assembly. The second of the following examples shows how to do this. You can do the same thing in the Assembly Linker. The third of the following examples shows how to do this. For more information, see Al.exe (Assembly Linker) and Working with Assemblies and the Global Assembly Cache
.
-linkres is the short form of -linkresource.
This compiler option is unavailable in Visual Studio and cannot be changed programmatically.
Compile in.prg and link to resource file rf.resource:
xsc -linkresource:rf.resource in.prg
Compile A.prg into a DLL, link to a native DLL N.dll, and put the output in the Global Assembly Cache (GAC). In this example, both A.dll and N.dll will reside in the GAC.
xsc -linkresource:N.dll -t:library A.prg
gacutil -i A.dll
This example does the same thing as the previous one, but by using Assembly Linker options.
xsc -t:module A.prg
al -out:A.dll A.netmodule -link:N.dll
gacutil -i A.dll