-linkresource (Visual Basic)-linkresource (Visual Basic)

创建指向托管资源的链接。Creates a link to a managed resource.

语法Syntax

-linkresource:filename[,identifier[,public|private]]  

oror

-linkres:filename[,identifier[,public|private]]  

自变量Arguments

filename
必需。Required. 要链接到程序集的资源文件。The resource file to link to the assembly. 如果文件名包含空格,则将名称括在引号内 (" ")。If the file name contains a space, enclose the name in quotation marks (" ").

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. 可以选择在程序集清单中指定文件是公共还是专用的,示例:-linkres:filename.res,myname.res,publicOptionally, you can specify whether the file is public or private in the assembly manifest, for example: -linkres:filename.res,myname.res,public. 默认情况下,filename 在程序集中是公共的。By default, filename is public in the assembly.

备注Remarks

-linkresource 选项不会将资源文件嵌入到输出文件中;使用 -resource 选项来执行此操作。The -linkresource option does not embed the resource file in the output file; use the -resource option to do this.

-linkresource 选项需要除 -target:module 之外的任一 -target 选项。The -linkresource option requires one of the -target options other than -target:module.

例如,如果 filename 是由 Resgen.exe(资源文件生成器)创建的或在开发环境中创建的 .NET Framework 资源文件,则可使用 System.Resources 命名空间中的成员来访问它。If filename is a .NET Framework resource file created, for example, by the Resgen.exe (Resource File Generator) or in the development environment, it can be accessed with members in the System.Resources namespace. (有关详细信息,请参阅 ResourceManager。)若要在运行时访问所有其他资源,请使用 Assembly 类中以 GetManifestResource 开头的方法。(For more information, see ResourceManager.) To access all other resources at run time, use the methods that begin with GetManifestResource in the Assembly class.

文件名可以是任何文件格式。The file name can be any file format. 例如,你可能希望生成程序集的本机 DLL 部分,从而可将它安装到全局程序集缓存中,并且可从该程序集中的托管代码访问它。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.

-linkresource 的缩写形式是 -linkresThe short form of -linkresource is -linkres.

备注

-linkresource 选项在Visual Studio 开发环境内无法使用;仅当从命令行编译时才可用。The -linkresource option is not available from the Visual Studio development environment; it is available only when you compile from the command line.

示例Example

下面的代码编译 in.vb 并链接到资源文件 rf.resourceThe following code compiles in.vb and links to resource file rf.resource.

vbc -linkresource:rf.resource in.vb  

请参阅See also