Assembly.GetManifestResourceStream Assembly.GetManifestResourceStream Assembly.GetManifestResourceStream Assembly.GetManifestResourceStream Method

定义

从此程序集加载指定的清单资源。Loads the specified manifest resource from this assembly.

重载

GetManifestResourceStream(Type, String) GetManifestResourceStream(Type, String) GetManifestResourceStream(Type, String)

从此程序集加载指定清单资源,清单资源的范围由指定类型的命名空间确定。Loads the specified manifest resource, scoped by the namespace of the specified type, from this assembly.

GetManifestResourceStream(String) GetManifestResourceStream(String) GetManifestResourceStream(String) GetManifestResourceStream(String)

从此程序集加载指定的清单资源。Loads the specified manifest resource from this assembly.

GetManifestResourceStream(Type, String) GetManifestResourceStream(Type, String) GetManifestResourceStream(Type, String)

从此程序集加载指定清单资源,清单资源的范围由指定类型的命名空间确定。Loads the specified manifest resource, scoped by the namespace of the specified type, from this assembly.

public:
 virtual System::IO::Stream ^ GetManifestResourceStream(Type ^ type, System::String ^ name);
public virtual System.IO.Stream GetManifestResourceStream (Type type, string name);
abstract member GetManifestResourceStream : Type * string -> System.IO.Stream
override this.GetManifestResourceStream : Type * string -> System.IO.Stream

参数

type
Type Type Type Type

其命名空间用于确定清单资源名的范围的类型。The type whose namespace is used to scope the manifest resource name.

name
String String String String

所请求的清单资源的名称(区分大小写)。The case-sensitive name of the manifest resource being requested.

返回

如果在编译期间没有指定任何资源,或者资源对调用方不可见,则为清单资源或者为 nullThe manifest resource; or null if no resources were specified during compilation or if the resource is not visible to the caller.

实现

异常

name 参数为空字符串 ("")。The name parameter is an empty string ("").

无法加载已找到的文件。A file that was found could not be loaded.

name 不是有效的程序集。name is not a valid assembly.

注解

例如, 如果为指定的type全名为 "MyNameSpace. MyClasses" 且name为 "Net", 则此方法重载将搜索名为 "MyNameSpace.Net" 的资源。For example, if the full name specified for type is "MyNameSpace.MyClasses" and name is "Net", this method overload searches for a resource named "MyNameSpace.Net".

清单资源是在编译时嵌入到程序集中的资源 (如图像文件)。A manifest resource is a resource (such as an image file) that is embedded in the assembly at compile time. 有关清单资源的详细信息, 请参阅 MSDN Library 中的Microsoft .NET Framework 资源基础知识For more information about manifest resources, see Microsoft .NET Framework Resource Basics in the MSDN Library.

仅当资源对调用方可见或调用方具有ReflectionPermission时, 才返回资源信息。Resource information is returned only if the resource is visible to the caller, or the caller has ReflectionPermission.

备注

如果访问另null一个程序集中的私有资源并且调用方不具有ReflectionPermission ReflectionPermissionFlag.MemberAccess标志, 则此方法返回。This method returns null if a private resource in another assembly is accessed and the caller does not have ReflectionPermission with the ReflectionPermissionFlag.MemberAccess flag.

如果程序集清单列出一个资源文件, GetManifestResourceStream则即使Stream此时无法在磁盘上找到资源文件, 也会返回一个对象。If the assembly manifest lists a resource file, GetManifestResourceStream returns a Stream object even if the resource file cannot be found on disk at the time. 如果找不到资源文件, 则将生成Stream的对象传递ResourceReader给构造函数会ArgumentException导致。If the resource file is not found, passing the resulting Stream object to the ResourceReader constructor causes an ArgumentException.

安全性

ReflectionPermission
当通过诸如InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])等机制后期绑定调用时。when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). 关联的枚举:MemberAccessAssociated enumeration: MemberAccess

另请参阅

GetManifestResourceStream(String) GetManifestResourceStream(String) GetManifestResourceStream(String) GetManifestResourceStream(String)

从此程序集加载指定的清单资源。Loads the specified manifest resource from this assembly.

public:
 virtual System::IO::Stream ^ GetManifestResourceStream(System::String ^ name);
public virtual System.IO.Stream GetManifestResourceStream (string name);
abstract member GetManifestResourceStream : string -> System.IO.Stream
override this.GetManifestResourceStream : string -> System.IO.Stream
Public Overridable Function GetManifestResourceStream (name As String) As Stream

参数

name
String String String String

所请求的清单资源的名称(区分大小写)。The case-sensitive name of the manifest resource being requested.

返回

如果在编译期间没有指定任何资源,或者资源对调用方不可见,则为清单资源或者为 nullThe manifest resource; or null if no resources were specified during compilation or if the resource is not visible to the caller.

实现

异常

name 参数为空字符串 ("")。The name parameter is an empty string ("").

适用于 Windows 应用商店应用的 .NET可移植类库中,改为捕获基类异常 IOExceptionIn the .NET for Windows Store apps or the Portable Class Library, catch the base class exception, IOException, instead.

无法加载已找到的文件。A file that was found could not be loaded.

name 不是有效的程序集。name is not a valid assembly.

注解

清单资源是在编译时嵌入到程序集中的资源 (如图像文件)。A manifest resource is a resource (such as an image file) that is embedded in the assembly at compile time. 有关清单资源的详细信息, 请参阅 MSDN Library 中的Microsoft .NET Framework 资源基础知识For more information about manifest resources, see Microsoft .NET Framework Resource Basics in the MSDN Library.

仅当资源对调用方可见或调用方具有ReflectionPermission时, 才返回资源信息。Resource information is returned only if the resource is visible to the caller, or the caller has ReflectionPermission.

备注

如果访问另null一个程序集中的私有资源并且调用方不具有ReflectionPermission ReflectionPermissionFlag.MemberAccess标志, 则此方法返回。This method returns null if a private resource in another assembly is accessed and the caller does not have ReflectionPermission with the ReflectionPermissionFlag.MemberAccess flag.

如果程序集清单列出一个资源文件, GetManifestResourceStream则即使Stream此时无法在磁盘上找到资源文件, 也会返回一个对象。If the assembly manifest lists a resource file, GetManifestResourceStream returns a Stream object even if the resource file cannot be found on disk at the time. 如果找不到资源文件, 则将生成Stream的对象传递ResourceReader给构造函数会ArgumentException导致。If the resource file is not found, passing the resulting Stream object to the ResourceReader constructor causes an ArgumentException.

安全性

ReflectionPermission
当通过诸如InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])等机制后期绑定调用时。when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). 关联的枚举:MemberAccessAssociated enumeration: MemberAccess

另请参阅

适用于