.NET CORE 之Assembly
一、定义
表示一个程序集,它是公共语言运行时应用程序的可重用、可版本化和自描述的构建块
二、备注
使用Assembly类加载程序集,探索程序集的元数据和组成部分,发现程序集中包含的类型,并创建这些类型的实例。
要获取表示当前加载到应用程序域(例如,简单项目的默认应用程序域)中的程序集的程序集对象数组,请使用AppDomain。GetAssemblys方法
要动态加载程序集,Assembly类提供以下静态方法(Visual Basic中的共享方法)。程序集被加载到发生加载操作的应用程序域中
加载程序集的推荐方法是使用加载方法,该方法通过其显示名称标识要加载的程序集(例如,“System.Windows.Forms,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”)。对程序集的搜索遵循运行时如何定位程序集中描述的规则。
ReflectionOnlyLoad和ReflectionOnlyLoadFrom方法使您能够加载程序集进行反射,但不能执行。例如,针对64位平台的程序集可以由在32位平台上运行的代码进行检查。
LoadFile和LoadFrom方法是为必须通过路径标识程序集的罕见情况提供的
Assembly类的许多成员提供有关程序集的信息。例如:
GetName方法返回一个AssemblyName对象,该对象提供对部件显示名称部分的访问。
GetCustomAttributes方法列出应用于程序集的属性。
GetFiles方法提供对程序集清单中文件的访问。
GetManifestResourceNames方法提供程序集清单中资源的名称。
Constructors
| Assembly() |
Initializes a new instance of the Assembly class. |
Properties
| CodeBase |
Obsolete.
Gets the location of the assembly as specified originally, for example, in an AssemblyName object. |
| CustomAttributes |
Gets a collection that contains this assembly's custom attributes. |
| DefinedTypes |
Gets a collection of the types defined in this assembly. |
| EntryPoint |
Gets the entry point of this assembly. |
| EscapedCodeBase |
Obsolete.
Gets the URI, including escape characters, that represents the codebase. |
| ExportedTypes |
Gets a collection of the public types defined in this assembly that are visible outside the assembly. |
| FullName |
Gets the display name of the assembly. |
| GlobalAssemblyCache |
Obsolete.
Gets a value indicating whether the assembly was loaded from the global assembly cache (.NET Framework only). |
| HostContext |
Gets the host context with which the assembly was loaded. |
| ImageRuntimeVersion |
Gets a string representing the version of the common language runtime (CLR) saved in the file containing the manifest. |
| IsCollectible |
Gets a value that indicates whether this assembly is held in a collectible AssemblyLoadContext. |
| IsDynamic |
Gets a value that indicates whether the current assembly was generated dynamically in the current process by using reflection emit. |
| IsFullyTrusted |
Gets a value that indicates whether the current assembly is loaded with full trust. |
| Location |
Gets the full path or UNC location of the loaded file that contains the manifest. |
| ManifestModule |
Gets the module that contains the manifest for the current assembly. |
| Modules |
Gets a collection that contains the modules in this assembly. |
| ReflectionOnly |
Gets a Boolean value indicating whether this assembly was loaded into the reflection-only context. |
| SecurityRuleSet |
Gets a value that indicates which set of security rules the common language runtime (CLR) enforces for this assembly. |
Methods
| CreateInstance(String) |
Locates the specified type from this assembly and creates an instance of it using the system activator, using case-sensitive search. |
| CreateInstance(String, Boolean) |
Locates the specified type from this assembly and creates an instance of it using the system activator, with optional case-sensitive search. |
| CreateInstance(String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[]) |
Locates the specified type from this assembly and creates an instance of it using the system activator, with optional case-sensitive search and having the specified culture, arguments, and binding and activation attributes. |
| CreateQualifiedName(String, String) |
Creates the name of a type qualified by the display name of its assembly. |
| Equals(Object) |
Determines whether this assembly and the specified object are equal. |
| GetAssembly(Type) |
Gets the currently loaded assembly in which the specified type is defined. |
| GetCallingAssembly() |
Returns the Assembly of the method that invoked the currently executing method. |
| GetCustomAttributes(Boolean) |
Gets all the custom attributes for this assembly. |
| GetCustomAttributes(Type, Boolean) |
Gets the custom attributes for this assembly as specified by type. |
| GetCustomAttributesData() |
Returns information about the attributes that have been applied to the current Assembly, expressed as CustomAttributeData objects. |
| GetEntryAssembly() |
Gets the process executable in the default application domain. In other application domains, this is the first executable that was executed by ExecuteAssembly(String). |
| GetExecutingAssembly() |
Gets the assembly that contains the code that is currently executing. |
| GetExportedTypes() |
Gets the public types defined in this assembly that are visible outside the assembly. |
| GetFile(String) |
Gets a FileStream for the specified file in the file table of the manifest of this assembly. |
| GetFiles() |
Gets the files in the file table of an assembly manifest. |
| GetFiles(Boolean) |
Gets the files in the file table of an assembly manifest, specifying whether to include resource modules. |
| GetForwardedTypes() | |
| GetHashCode() |
Returns the hash code for this instance. |
| GetLoadedModules() |
Gets all the loaded modules that are part of this assembly. |
| GetLoadedModules(Boolean) |
Gets all the loaded modules that are part of this assembly, specifying whether to include resource modules. |
| GetManifestResourceInfo(String) |
Returns information about how the given resource has been persisted. |
| GetManifestResourceNames() |
Returns the names of all the resources in this assembly. |
| GetManifestResourceStream(String) |
Loads the specified manifest resource from this assembly. |
| GetManifestResourceStream(Type, String) |
Loads the specified manifest resource, scoped by the namespace of the specified type, from this assembly. |
| GetModule(String) |
Gets the specified module in this assembly. |
| GetModules() |
Gets all the modules that are part of this assembly. |
| GetModules(Boolean) |
Gets all the modules that are part of this assembly, specifying whether to include resource modules. |
| GetName() |
Gets an AssemblyName for this assembly. |
| GetName(Boolean) |
Gets an AssemblyName for this assembly, setting the codebase as specified by |
| GetObjectData(SerializationInfo, StreamingContext) |
Gets serialization information with all of the data needed to reinstantiate this assembly. |
| GetReferencedAssemblies() |
Gets the AssemblyName objects for all the assemblies referenced by this assembly. |
| GetSatelliteAssembly(CultureInfo) |
Gets the satellite assembly for the specified culture. |
| GetSatelliteAssembly(CultureInfo, Version) |
Gets the specified version of the satellite assembly for the specified culture. |
| GetType() |
Gets the Type of the current instance. (Inherited from Object) |
| GetType(String) |
Gets the Type object with the specified name in the assembly instance. |
| GetType(String, Boolean) |
Gets the Type object with the specified name in the assembly instance and optionally throws an exception if the type is not found. |
| GetType(String, Boolean, Boolean) |
Gets the Type object with the specified name in the assembly instance, with the options of ignoring the case, and of throwing an exception if the type is not found. |
| GetTypes() |
Gets the types defined in this assembly. |
| IsDefined(Type, Boolean) |
Indicates whether or not a specified attribute has been applied to the assembly. |
| Load(AssemblyName) |
Loads an assembly given its AssemblyName. |
| Load(Byte[]) |
Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the application domain of the caller. |
| Load(Byte[], Byte[]) |
Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols for the assembly. The assembly is loaded into the application domain of the caller. |
| Load(String) |
Loads an assembly with the specified name. |
| LoadFile(String) |
Loads the contents of an assembly file on the specified path. |
| LoadFrom(String) |
Loads an assembly given its file name or path. |
| LoadFrom(String, Byte[], AssemblyHashAlgorithm) |
Loads an assembly given its file name or path, hash value, and hash algorithm. |
| LoadModule(String, Byte[]) |
Loads the module, internal to this assembly, with a common object file format (COFF)-based image containing an emitted module, or a resource file. |
| LoadModule(String, Byte[], Byte[]) |
Loads the module, internal to this assembly, with a common object file format (COFF)-based image containing an emitted module, or a resource file. The raw bytes representing the symbols for the module are also loaded. |
| LoadWithPartialName(String) |
Obsolete.
Loads an assembly from the application directory or from the global assembly cache using a partial name. |
| MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
| ReflectionOnlyLoad(Byte[]) |
Obsolete.
Loads the assembly from a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the reflection-only context of the caller's application domain. |
| ReflectionOnlyLoad(String) |
Obsolete.
Loads an assembly into the reflection-only context, given its display name. |
| ReflectionOnlyLoadFrom(String) |
Obsolete.
Loads an assembly into the reflection-only context, given its path. |
| ToString() |
Returns the full name of the assembly, also known as the display name. |
| UnsafeLoadFrom(String) |
Loads an assembly into the load-from context, bypassing some security checks. |
Operators
| Equality(Assembly, Assembly) |
Indicates whether two Assembly objects are equal. |
| Inequality(Assembly, Assembly) |
Indicates whether two Assembly objects are not equal. |
Events
| ModuleResolve |
Occurs when the common language runtime class loader cannot resolve a reference to an internal module of an assembly through normal means. |
Extension Methods
| GetExportedTypes(Assembly) | |
| GetModules(Assembly) | |
| GetTypes(Assembly) | |
| GetCustomAttribute(Assembly, Type) |
Retrieves a custom attribute of a specified type that is applied to a specified assembly. |
| GetCustomAttribute<T>(Assembly) |
Retrieves a custom attribute of a specified type that is applied to a specified assembly. |
| GetCustomAttributes(Assembly) |
Retrieves a collection of custom attributes that are applied to a specified assembly. |
| GetCustomAttributes(Assembly, Type) |
Retrieves a collection of custom attributes of a specified type that are applied to a specified assembly. |
| GetCustomAttributes<T>(Assembly) |
Retrieves a collection of custom attributes of a specified type that are applied to a specified assembly. |
| IsDefined(Assembly, Type) |
Indicates whether custom attributes of a specified type are applied to a specified assembly. |
| TryGetRawMetadata(Assembly, Byte*, Int32) |
Retrieves the metadata section of the assembly, for use with MetadataReader. |
Applies to
| Product | Versions |
|---|---|
| .NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7 Preview 1 |
| .NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
| .NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
| UWP | 10.0 |
| Xamarin.iOS | 10.8 |
| Xamarin.Mac | 3.0 |
Thread
posted on 2022-03-15 23:16 topguntopgun 阅读(874) 评论(0) 收藏 举报
浙公网安备 33010602011771号