Assembly Assembly Assembly Assembly Class

定义

表示一个程序集,它是一个可重用、无版本冲突并且可自我描述的公共语言运行时应用程序构建基块。Represents an assembly, which is a reusable, versionable, and self-describing building block of a common language runtime application.

public ref class Assembly abstract : System::Reflection::ICustomAttributeProvider, System::Runtime::InteropServices::_Assembly, System::Runtime::Serialization::ISerializable, System::Security::IEvidenceFactory
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class Assembly : System.Reflection.ICustomAttributeProvider, System.Runtime.InteropServices._Assembly, System.Runtime.Serialization.ISerializable, System.Security.IEvidenceFactory
type Assembly = class
    interface ICustomAttributeProvider
    interface _Assembly
    interface IEvidenceFactory
    interface ISerializable
Public MustInherit Class Assembly
Implements _Assembly, ICustomAttributeProvider, IEvidenceFactory, ISerializable
继承
AssemblyAssemblyAssemblyAssembly
派生
属性
实现

示例

下面的代码示例演示如何获取当前正在执行的程序集、创建该程序集中包含的类型的实例, 以及使用后期绑定调用类型的方法之一。The following code example shows how to obtain the currently executing assembly, create an instance of a type contained in that assembly, and invoke one of the type's methods with late binding. 为此, 该代码示例定义了一个名为Example的类, 其中包含SampleMethod一个名为的方法。For this purpose, the code example defines a class named Example, with a method named SampleMethod. 类的构造函数接受一个整数, 该整数用于计算方法的返回值。The constructor of the class accepts an integer, which is used to compute the return value of the method.

此代码示例还演示了如何使用GetName方法AssemblyName获取可用于分析程序集的全名的对象。The code example also demonstrates the use of the GetName method to obtain an AssemblyName object that can be used to parse the full name of the assembly. 该示例显示程序集的版本号、 CodeBase属性EntryPoint和属性。The example displays the version number of the assembly, the CodeBase property, and the EntryPoint property.

using namespace System;
using namespace System::Reflection;
using namespace System::Security::Permissions;

[assembly:AssemblyVersionAttribute("1.0.2000.0")];

public ref class Example
{
private: 
    int factor;

public:
    Example(int f)
    {
        factor = f;
    }

    int SampleMethod(int x) 
    { 
        Console::WriteLine("\nExample->SampleMethod({0}) executes.", x);
        return x * factor;
    }
};

void main()
{
    Assembly^ assem = Example::typeid->Assembly;

    Console::WriteLine("Assembly Full Name:");
    Console::WriteLine(assem->FullName);

    // The AssemblyName type can be used to parse the full name.
    AssemblyName^ assemName = assem->GetName();
    Console::WriteLine("\nName: {0}", assemName->Name);
    Console::WriteLine("Version: {0}.{1}", 
        assemName->Version->Major, assemName->Version->Minor);

    Console::WriteLine("\nAssembly CodeBase:");
    Console::WriteLine(assem->CodeBase);

    // Create an object from the assembly, passing in the correct number and
    // type of arguments for the constructor.
    Object^ o = assem->CreateInstance("Example", false, 
        BindingFlags::ExactBinding, 
        nullptr, gcnew array<Object^> { 2 }, nullptr, nullptr);

    // Make a late-bound call to an instance method of the object.    
    MethodInfo^ m = assem->GetType("Example")->GetMethod("SampleMethod");
    Object^ ret = m->Invoke(o, gcnew array<Object^> { 42 });
    Console::WriteLine("SampleMethod returned {0}.", ret);

    Console::WriteLine("\nAssembly entry point:");
    Console::WriteLine(assem->EntryPoint);
}

/* This code example produces output similar to the following:

Assembly Full Name:
source, Version=1.0.2000.0, Culture=neutral, PublicKeyToken=null

Name: source
Version: 1.0

Assembly CodeBase:
file:///C:/sdtree/AssemblyClass/cpp/source.exe

Example->SampleMethod(42) executes.
SampleMethod returned 84.

Assembly entry point:
UInt32 _mainCRTStartup()
 */
using System;
using System.Reflection;
using System.Security.Permissions;

[assembly:AssemblyVersionAttribute("1.0.2000.0")]

public class Example
{
    private int factor;
    public Example(int f)
    {
        factor = f;
    }

    public int SampleMethod(int x) 
    { 
        Console.WriteLine("\nExample.SampleMethod({0}) executes.", x);
        return x * factor;
    }

    public static void Main()
    {
        Assembly assem = typeof(Example).Assembly;

        Console.WriteLine("Assembly Full Name:");
        Console.WriteLine(assem.FullName);

        // The AssemblyName type can be used to parse the full name.
        AssemblyName assemName = assem.GetName();
        Console.WriteLine("\nName: {0}", assemName.Name);
        Console.WriteLine("Version: {0}.{1}", 
            assemName.Version.Major, assemName.Version.Minor);

        Console.WriteLine("\nAssembly CodeBase:");
        Console.WriteLine(assem.CodeBase);

        // Create an object from the assembly, passing in the correct number
        // and type of arguments for the constructor.
        Object o = assem.CreateInstance("Example", false, 
            BindingFlags.ExactBinding, 
            null, new Object[] { 2 }, null, null);

        // Make a late-bound call to an instance method of the object.    
        MethodInfo m = assem.GetType("Example").GetMethod("SampleMethod");
        Object ret = m.Invoke(o, new Object[] { 42 });
        Console.WriteLine("SampleMethod returned {0}.", ret);

        Console.WriteLine("\nAssembly entry point:");
        Console.WriteLine(assem.EntryPoint);
    }
}

/* This code example produces output similar to the following:

Assembly Full Name:
source, Version=1.0.2000.0, Culture=neutral, PublicKeyToken=null

Name: source
Version: 1.0

Assembly CodeBase:
file:///C:/sdtree/AssemblyClass/cs/source.exe

Example.SampleMethod(42) executes.
SampleMethod returned 84.

Assembly entry point:
Void Main()
 */
Imports System
Imports System.Reflection
Imports System.Security.Permissions

<assembly: AssemblyVersionAttribute("1.0.2000.0")>

Public Class Example
    Private factor As Integer
    
    Public Sub New(ByVal f As Integer) 
        factor = f
    End Sub 
    
    Public Function SampleMethod(ByVal x As Integer) As Integer 
        Console.WriteLine(vbCrLf & "Example.SampleMethod({0}) executes.", x)
        Return x * factor
    End Function 
    
    Public Shared Sub Main() 
        Dim assem As Assembly = GetType(Example).Assembly
        
        Console.WriteLine("Assembly Full Name:")
        Console.WriteLine(assem.FullName)
        
        ' The AssemblyName type can be used to parse the full name.
        Dim assemName As AssemblyName = assem.GetName()
        Console.WriteLine(vbLf + "Name: {0}", assemName.Name)
        Console.WriteLine("Version: {0}.{1}", assemName.Version.Major, _
            assemName.Version.Minor)
        
        Console.WriteLine(vbLf + "Assembly CodeBase:")
        Console.WriteLine(assem.CodeBase)
        
        ' Create an object from the assembly, passing in the correct number
        ' and type of arguments for the constructor.
        Dim o As Object = assem.CreateInstance("Example", False, _
            BindingFlags.ExactBinding, Nothing, _
            New Object() { 2 }, Nothing, Nothing)
        
        ' Make a late-bound call to an instance method of the object.    
        Dim m As MethodInfo = assem.GetType("Example").GetMethod("SampleMethod")
        Dim ret As Object = m.Invoke(o, New Object() { 42 })
        Console.WriteLine("SampleMethod returned {0}.", ret)
        
        Console.WriteLine(vbCrLf & "Assembly entry point:")
        Console.WriteLine(assem.EntryPoint)
    
    End Sub 
End Class 

' This code example produces output similar to the following:
'
'Assembly Full Name:
'source, Version=1.0.2000.0, Culture=neutral, PublicKeyToken=null
'
'Name: source
'Version: 1.0
'
'Assembly CodeBase:
'file:///C:/sdtree/AssemblyClass/vb/source.exe
'
'Example.SampleMethod(42) executes.
'SampleMethod returned 84.
'
'Assembly entry point:
'Void Main()
' 

注解

Assembly使用类加载程序集、浏览程序集的元数据和构成部分、发现程序集中包含的类型以及创建这些类型的实例。Use the Assembly class to load assemblies, to explore the metadata and constituent parts of assemblies, to discover the types contained in assemblies, and to create instances of those types.

若要获取表示当前Assembly加载到应用程序域中的程序集 (例如, 简单项目的默认应用程序域) 的对象数组, 请AppDomain.GetAssemblies使用方法。To get an array of Assembly objects representing the assemblies currently loaded into an application domain (for example, the default application domain of a simple project), use the AppDomain.GetAssemblies method.

为了动态加载程序集, Assembly类提供以下静态方法 (Shared Visual Basic 中的方法)。To load assemblies dynamically, the Assembly class provides the following static methods (Shared methods in Visual Basic). 将程序集加载到发生加载操作的应用程序域中。Assemblies are loaded into the application domain where the load operation occurs.

  • 加载程序集的建议方法是使用Load方法, 该方法标识要由其显示名称 (例如 "b77a5c561934e089, Version = 2.0.0.0, Culture = 中立, PublicKeyToken =") 加载的程序集。The recommended way to load assemblies is to use the Load method, which identifies the assembly to be loaded by its display name (for example, "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"). 该程序集的搜索遵循运行时如何定位程序集中所述的规则。The search for the assembly follows the rules described in How the Runtime Locates Assemblies.

  • 使用ReflectionOnlyLoadReflectionOnlyLoadFrom方法, 可以加载用于反射的程序集, 但不能加载用于执行的程序集。The ReflectionOnlyLoad and ReflectionOnlyLoadFrom methods enable you to load an assembly for reflection, but not for execution. 例如, 可通过在32位平台上运行的代码来检查面向64位平台的程序集。For example, an assembly that targets a 64-bit platform can be examined by code that is running on a 32-bit platform.

  • 对于LoadFile程序LoadFrom集必须按路径进行标识的罕见方案, 提供了和方法。The LoadFile and LoadFrom methods are provided for rare scenarios in which an assembly must be identified by path.

若要获取Assembly当前正在执行的程序集的对象, GetExecutingAssembly请使用方法。To get an Assembly object for the currently executing assembly, use the GetExecutingAssembly method.

Assembly类的许多成员提供有关程序集的信息。Many members of the Assembly class provide information about an assembly. 例如:For example:

GetTypes方法列出程序集中的所有类型。The GetTypes method lists all the types in the assembly. GetExportedTypes方法列出对程序集外部的调用方可见的类型。The GetExportedTypes method lists the types that are visible to callers outside the assembly. GetType方法可用于在程序集中搜索特定类型。The GetType method can be used to search for a particular type in the assembly. CreateInstance方法可用于在程序集中搜索和创建类型的实例。The CreateInstance method can be used to search for and create instances of types in the assembly.

有关程序集的详细信息, 请参阅应用程序域主题中的 "应用程序域和程序集" 一节。For more information on assemblies, see the "Application Domains and Assemblies" section in the Application Domains topic.

构造函数

Assembly() Assembly() Assembly() Assembly()

初始化 Assembly 类的新实例。Initializes a new instance of the Assembly class.

属性

CodeBase CodeBase CodeBase CodeBase

获取最初指定的程序集的位置,例如,在 AssemblyName 对象中指定的位置。Gets the location of the assembly as specified originally, for example, in an AssemblyName object.

CustomAttributes CustomAttributes CustomAttributes CustomAttributes

获取包含此程序集自定义属性的集合。Gets a collection that contains this assembly's custom attributes.

DefinedTypes DefinedTypes DefinedTypes DefinedTypes

获取定义在此程序集中的类型的集合。Gets a collection of the types defined in this assembly.

EntryPoint EntryPoint EntryPoint EntryPoint

获取此程序集的入口点。Gets the entry point of this assembly.

EscapedCodeBase EscapedCodeBase EscapedCodeBase EscapedCodeBase

获取 URI,包括表示基本代码的转义符。Gets the URI, including escape characters, that represents the codebase.

Evidence Evidence Evidence Evidence

获取此程序集的证据。Gets the evidence for this assembly.

ExportedTypes ExportedTypes ExportedTypes ExportedTypes

获取此程序集中定义的公共类型的集合,这些公共类型在程序集外可见。Gets a collection of the public types defined in this assembly that are visible outside the assembly.

FullName FullName FullName FullName

获取程序集的显示名称。Gets the display name of the assembly.

GlobalAssemblyCache GlobalAssemblyCache GlobalAssemblyCache GlobalAssemblyCache

获取一个值,该值指示程序集是否是从全局程序集缓存加载的。Gets a value indicating whether the assembly was loaded from the global assembly cache.

HostContext HostContext HostContext HostContext

获取用于加载程序集的主机上下文。Gets the host context with which the assembly was loaded.

ImageRuntimeVersion ImageRuntimeVersion ImageRuntimeVersion ImageRuntimeVersion

获取表示公共语言运行时 (CLR) 的版本的字符串,该信息保存在包含清单的文件中。Gets a string representing the version of the common language runtime (CLR) saved in the file containing the manifest.

IsCollectible IsCollectible IsCollectible IsCollectible

获取一个值,该值指示此程序集是否保留在可回收的 AssemblyLoadContext 中。Gets a value that indicates whether this assembly is held in a collectible AssemblyLoadContext.

IsDynamic IsDynamic IsDynamic IsDynamic

获取一个值,该值指示当前程序集是否是通过使用反射发出在当前进程中动态生成的。Gets a value that indicates whether the current assembly was generated dynamically in the current process by using reflection emit.

IsFullyTrusted IsFullyTrusted IsFullyTrusted IsFullyTrusted

获取一个值,该值指示当前程序集是否是以完全信任方式加载的。Gets a value that indicates whether the current assembly is loaded with full trust.

Location Location Location Location

获取包含清单的已加载文件的完整路径或 UNC 位置。Gets the full path or UNC location of the loaded file that contains the manifest.

ManifestModule ManifestModule ManifestModule ManifestModule

获取包含当前程序集清单的模块。Gets the module that contains the manifest for the current assembly.

Modules Modules Modules Modules

获取包含此程序集中模块的集合。Gets a collection that contains the modules in this assembly.

PermissionSet PermissionSet PermissionSet PermissionSet

获取当前程序集的授予集。Gets the grant set of the current assembly.

ReflectionOnly ReflectionOnly ReflectionOnly ReflectionOnly

获取 Boolean 值,该值指示此程序集是否被加载到只反射上下文中。Gets a Boolean value indicating whether this assembly was loaded into the reflection-only context.

SecurityRuleSet SecurityRuleSet SecurityRuleSet SecurityRuleSet

获取一个值,该值指示公共语言运行时 (CLR) 对此程序集强制执行的安全规则集。Gets a value that indicates which set of security rules the common language runtime (CLR) enforces for this assembly.

方法

CreateInstance(String) CreateInstance(String) CreateInstance(String) 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) CreateInstance(String, Boolean) CreateInstance(String, Boolean) 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[]) CreateInstance(String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[]) CreateInstance(String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[]) 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) CreateQualifiedName(String, String) CreateQualifiedName(String, String) CreateQualifiedName(String, String)

创建由类型的程序集的显示名称限定的类型的名称。Creates the name of a type qualified by the display name of its assembly.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定此程序集和指定的对象是否相等。Determines whether this assembly and the specified object are equal.

GetAssembly(Type) GetAssembly(Type) GetAssembly(Type) GetAssembly(Type)

获取在其中定义指定类型的当前加载的程序集。Gets the currently loaded assembly in which the specified type is defined.

GetCallingAssembly() GetCallingAssembly() GetCallingAssembly() GetCallingAssembly()

返回方法(该方法调用当前正在执行的方法)的 AssemblyReturns the Assembly of the method that invoked the currently executing method.

GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean)

获取此程序集的所有自定义属性。Gets all the custom attributes for this assembly.

GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean)

获取按类型指定的此程序集的自定义属性。Gets the custom attributes for this assembly as specified by type.

GetCustomAttributesData() GetCustomAttributesData() GetCustomAttributesData() GetCustomAttributesData()

返回有关已应用于当前 Assembly(表示为 CustomAttributeData 对象)的特性的信息。Returns information about the attributes that have been applied to the current Assembly, expressed as CustomAttributeData objects.

GetEntryAssembly() GetEntryAssembly() GetEntryAssembly() GetEntryAssembly()

获取默认应用程序域中的进程可执行文件。Gets the process executable in the default application domain. 在其他的应用程序域中,这是由 ExecuteAssembly(String) 执行的第一个可执行文件。In other application domains, this is the first executable that was executed by ExecuteAssembly(String).

GetExecutingAssembly() GetExecutingAssembly() GetExecutingAssembly() GetExecutingAssembly()

获取包含当前执行的代码的程序集。Gets the assembly that contains the code that is currently executing.

GetExportedTypes() GetExportedTypes() GetExportedTypes() GetExportedTypes()

获取此程序集中定义的公共类型,这些公共类型在程序集外可见。Gets the public types defined in this assembly that are visible outside the assembly.

GetFile(String) GetFile(String) GetFile(String) GetFile(String)

获取此程序集清单的文件表中指定文件的 FileStreamGets a FileStream for the specified file in the file table of the manifest of this assembly.

GetFiles() GetFiles() GetFiles() GetFiles()

获取程序集清单文件表中的文件。Gets the files in the file table of an assembly manifest.

GetFiles(Boolean) GetFiles(Boolean) GetFiles(Boolean) GetFiles(Boolean)

获取程序集清单的文件表中的文件,指定是否包括资源模块。Gets the files in the file table of an assembly manifest, specifying whether to include resource modules.

GetForwardedTypes() GetForwardedTypes() GetForwardedTypes() GetForwardedTypes()
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

GetLoadedModules() GetLoadedModules() GetLoadedModules() GetLoadedModules()

获取作为此程序集的一部分的所有加载模块。Gets all the loaded modules that are part of this assembly.

GetLoadedModules(Boolean) GetLoadedModules(Boolean) GetLoadedModules(Boolean) GetLoadedModules(Boolean)

获取属于此程序集的所有已加载模块,同时指定是否包括资源模块。Gets all the loaded modules that are part of this assembly, specifying whether to include resource modules.

GetManifestResourceInfo(String) GetManifestResourceInfo(String) GetManifestResourceInfo(String) GetManifestResourceInfo(String)

返回关于给定资源如何保持的信息。Returns information about how the given resource has been persisted.

GetManifestResourceNames() GetManifestResourceNames() GetManifestResourceNames() GetManifestResourceNames()

返回此程序集中的所有资源的名称。Returns the names of all the resources in 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) GetManifestResourceStream(Type, String)

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

GetModule(String) GetModule(String) GetModule(String) GetModule(String)

获取此程序集中的指定模块。Gets the specified module in this assembly.

GetModules() GetModules() GetModules() GetModules()

获取作为此程序集的一部分的所有模块。Gets all the modules that are part of this assembly.

GetModules(Boolean) GetModules(Boolean) GetModules(Boolean) GetModules(Boolean)

获取属于此程序集的所有模块,同时指定是否包括资源模块。Gets all the modules that are part of this assembly, specifying whether to include resource modules.

GetName() GetName() GetName() GetName()

获取此程序集的 AssemblyNameGets an AssemblyName for this assembly.

GetName(Boolean) GetName(Boolean) GetName(Boolean) GetName(Boolean)

获取此程序集的 AssemblyName,并按 copiedName 指定的那样设置基本代码。Gets an AssemblyName for this assembly, setting the codebase as specified by copiedName.

GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

获取序列化信息,其中包含重新实例化此程序集所需的所有数据。Gets serialization information with all of the data needed to reinstantiate this assembly.

GetReferencedAssemblies() GetReferencedAssemblies() GetReferencedAssemblies() GetReferencedAssemblies()

获取此程序集引用的所有程序集的 AssemblyName 对象。Gets the AssemblyName objects for all the assemblies referenced by this assembly.

GetSatelliteAssembly(CultureInfo) GetSatelliteAssembly(CultureInfo) GetSatelliteAssembly(CultureInfo) GetSatelliteAssembly(CultureInfo)

获取指定区域性的附属程序集。Gets the satellite assembly for the specified culture.

GetSatelliteAssembly(CultureInfo, Version) GetSatelliteAssembly(CultureInfo, Version) GetSatelliteAssembly(CultureInfo, Version) GetSatelliteAssembly(CultureInfo, Version)

获取指定区域性的附属程序集的指定版本。Gets the specified version of the satellite assembly for the specified culture.

GetType() GetType() GetType() GetType()
GetType(String) GetType(String) GetType(String) GetType(String)

获取程序集实例中具有指定名称的 Type 对象。Gets the Type object with the specified name in the assembly instance.

GetType(String, Boolean) GetType(String, Boolean) GetType(String, Boolean) GetType(String, Boolean)

获取程序集实例中具有指定名称的 Type 对象,并选择在找不到该类型时引发异常。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) GetType(String, Boolean, Boolean) GetType(String, Boolean, Boolean) GetType(String, Boolean, Boolean)

获取程序集实例中具有指定名称的 Type 对象,带有忽略大小写和在找不到该类型时引发异常的选项。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() GetTypes() GetTypes() GetTypes()

获取此程序集中定义的类型。Gets the types defined in this assembly.

IsDefined(Type, Boolean) IsDefined(Type, Boolean) IsDefined(Type, Boolean) IsDefined(Type, Boolean)

指示指定的属性是否已应用于该程序集。Indicates whether or not a specified attribute has been applied to the assembly.

Load(AssemblyName) Load(AssemblyName) Load(AssemblyName) Load(AssemblyName)

在给定程序集的 AssemblyName 的情况下,加载程序集。Loads an assembly given its AssemblyName.

Load(AssemblyName, Evidence) Load(AssemblyName, Evidence) Load(AssemblyName, Evidence) Load(AssemblyName, Evidence)

在给定程序集的 AssemblyName 的情况下,加载程序集。Loads an assembly given its AssemblyName. 使用提供的证据将该程序集加载到调用方的域中。The assembly is loaded into the domain of the caller using the supplied evidence.

Load(Byte[]) Load(Byte[]) Load(Byte[]) Load(Byte[])

加载带有基于通用对象文件格式 (COFF) 的映像的程序集,该映像包含已发出的程序集。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[]) Load(Byte[], Byte[]) Load(Byte[], Byte[]) Load(Byte[], Byte[])

加载带有基于通用对象文件格式 (COFF) 的映像的程序集,此映像包含一个已发出的程序集,并且还可以选择包括程序集的符号。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(Byte[], Byte[], Evidence) Load(Byte[], Byte[], Evidence) Load(Byte[], Byte[], Evidence) Load(Byte[], Byte[], Evidence)

加载带有基于通用对象文件格式 (COFF) 的映像的程序集,此映像包含一个已发出的程序集,并且还可选择包括程序集的符号和证据。Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols and evidence for the assembly. 此程序集将会加载到调用方的应用程序域中。The assembly is loaded into the application domain of the caller.

Load(Byte[], Byte[], SecurityContextSource) Load(Byte[], Byte[], SecurityContextSource) Load(Byte[], Byte[], SecurityContextSource) Load(Byte[], Byte[], SecurityContextSource)

加载带有基于通用对象文件格式 (COFF) 的映像的程序集,此映像包含一个已发出的程序集,并且还可选择包括符号和指定安全上下文的源。Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols and specifying the source for the security context. 此程序集将会加载到调用方的应用程序域中。The assembly is loaded into the application domain of the caller.

Load(String) Load(String) Load(String) Load(String)

通过给定程序集的长格式名称加载程序集。Loads an assembly given the long form of its name.

Load(String, Evidence) Load(String, Evidence) Load(String, Evidence) Load(String, Evidence)

通过给定的程序集的显示名称来加载程序集,使用提供的证据将程序集加载到调用方的域中。Loads an assembly given its display name, loading the assembly into the domain of the caller using the supplied evidence.

LoadFile(String) LoadFile(String) LoadFile(String) LoadFile(String)

加载指定路径上的程序集文件的内容。Loads the contents of an assembly file on the specified path.

LoadFile(String, Evidence) LoadFile(String, Evidence) LoadFile(String, Evidence) LoadFile(String, Evidence)

通过给定的程序集的路径来加载程序集,使用提供的证据将程序集加载到调用方的域中。Loads an assembly given its path, loading the assembly into the domain of the caller using the supplied evidence.

LoadFrom(String) LoadFrom(String) LoadFrom(String) LoadFrom(String)

已知程序集的文件名或路径,加载程序集。Loads an assembly given its file name or path.

LoadFrom(String, Byte[], AssemblyHashAlgorithm) LoadFrom(String, Byte[], AssemblyHashAlgorithm) LoadFrom(String, Byte[], AssemblyHashAlgorithm) LoadFrom(String, Byte[], AssemblyHashAlgorithm)

通过给定程序集文件名或路径、哈希值及哈希算法来加载程序集。Loads an assembly given its file name or path, hash value, and hash algorithm.

LoadFrom(String, Evidence) LoadFrom(String, Evidence) LoadFrom(String, Evidence) LoadFrom(String, Evidence)

在给定程序集的文件名或路径并提供安全证据的情况下,加载程序集。Loads an assembly given its file name or path and supplying security evidence.

LoadFrom(String, Evidence, Byte[], AssemblyHashAlgorithm) LoadFrom(String, Evidence, Byte[], AssemblyHashAlgorithm) LoadFrom(String, Evidence, Byte[], AssemblyHashAlgorithm) LoadFrom(String, Evidence, Byte[], AssemblyHashAlgorithm)

通过给定程序集文件名或路径、安全证据、哈希值及哈希算法来加载程序集。Loads an assembly given its file name or path, security evidence, hash value, and hash algorithm.

LoadModule(String, Byte[]) LoadModule(String, Byte[]) LoadModule(String, Byte[]) LoadModule(String, Byte[])

加载带有基于通用对象文件格式 (COFF) 的映像(包含已发出的模块)或资源文件的模块(该模块相对于此程序集是内部的)。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[]) LoadModule(String, Byte[], Byte[]) LoadModule(String, Byte[], Byte[]) LoadModule(String, Byte[], Byte[])

加载带有基于通用对象文件格式 (COFF) 的映像(包含已发出的模块)或资源文件的模块(该模块相对于此程序集是内部的)。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) LoadWithPartialName(String) LoadWithPartialName(String) LoadWithPartialName(String)

使用部分名称从应用程序目录或从全局程序集缓存加载程序集。Loads an assembly from the application directory or from the global assembly cache using a partial name.

LoadWithPartialName(String, Evidence) LoadWithPartialName(String, Evidence) LoadWithPartialName(String, Evidence) LoadWithPartialName(String, Evidence)

使用部分名称从应用程序目录或从全局程序集缓存加载程序集。Loads an assembly from the application directory or from the global assembly cache using a partial name. 使用提供的证据将该程序集加载到调用方的域中。The assembly is loaded into the domain of the caller using the supplied evidence.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[]) ReflectionOnlyLoad(Byte[])

加载来自基于通用对象文件格式 (COFF) 的映像的程序集,该映像包含已发出的程序集。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) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String) ReflectionOnlyLoad(String)

将给定显示名称的程序集加载到只反射上下文中。Loads an assembly into the reflection-only context, given its display name.

ReflectionOnlyLoadFrom(String) ReflectionOnlyLoadFrom(String) ReflectionOnlyLoadFrom(String) ReflectionOnlyLoadFrom(String)

将给定路径的程序集加载到只反射上下文中。Loads an assembly into the reflection-only context, given its path.

ToString() ToString() ToString() ToString()

返回程序集的全名,即所谓的显示名称。Returns the full name of the assembly, also known as the display name.

UnsafeLoadFrom(String) UnsafeLoadFrom(String) UnsafeLoadFrom(String) UnsafeLoadFrom(String)

绕过某些安全检查,将程序集加载到加载源上下文中。Loads an assembly into the load-from context, bypassing some security checks.

事件

ModuleResolve ModuleResolve ModuleResolve ModuleResolve

当公共语言运行时类加载程序不能通过正常方法解析对程序集的内部模块的引用时发生。Occurs when the common language runtime class loader cannot resolve a reference to an internal module of an assembly through normal means.

操作员

Equality(Assembly, Assembly) Equality(Assembly, Assembly) Equality(Assembly, Assembly) Equality(Assembly, Assembly)

指示两个 Assembly 对象是否相等。Indicates whether two Assembly objects are equal.

Inequality(Assembly, Assembly) Inequality(Assembly, Assembly) Inequality(Assembly, Assembly) Inequality(Assembly, Assembly)

指示两个 Assembly 对象是否不相等。Indicates whether two Assembly objects are not equal.

显式界面实现

ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)
ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean)
_Assembly.GetType() _Assembly.GetType() _Assembly.GetType() _Assembly.GetType()

返回当前实例的类型。Returns the type of the current instance.

扩展方法

GetExportedTypes(Assembly) GetExportedTypes(Assembly) GetExportedTypes(Assembly) GetExportedTypes(Assembly)
GetModules(Assembly) GetModules(Assembly) GetModules(Assembly) GetModules(Assembly)
GetTypes(Assembly) GetTypes(Assembly) GetTypes(Assembly) GetTypes(Assembly)
GetCustomAttribute(Assembly, Type) GetCustomAttribute(Assembly, Type) GetCustomAttribute(Assembly, Type) GetCustomAttribute(Assembly, Type)

检索应用于指定程序集的指定类型的自定义特性。Retrieves a custom attribute of a specified type that is applied to a specified assembly.

GetCustomAttribute<T>(Assembly) GetCustomAttribute<T>(Assembly) GetCustomAttribute<T>(Assembly) GetCustomAttribute<T>(Assembly)

检索应用于指定程序集的指定类型的自定义特性。Retrieves a custom attribute of a specified type that is applied to a specified assembly.

GetCustomAttributes(Assembly) GetCustomAttributes(Assembly) GetCustomAttributes(Assembly) GetCustomAttributes(Assembly)

检索应用于指定程序集的自定义特性集合。Retrieves a collection of custom attributes that are applied to a specified assembly.

GetCustomAttributes(Assembly, Type) GetCustomAttributes(Assembly, Type) GetCustomAttributes(Assembly, Type) GetCustomAttributes(Assembly, Type)

检索应用于指定程序集的指定类型的自定义特性集合Retrieves a collection of custom attributes of a specified type that are applied to a specified assembly.

GetCustomAttributes<T>(Assembly) GetCustomAttributes<T>(Assembly) GetCustomAttributes<T>(Assembly) GetCustomAttributes<T>(Assembly)

检索应用于指定程序集的指定类型的自定义特性集合Retrieves a collection of custom attributes of a specified type that are applied to a specified assembly.

IsDefined(Assembly, Type) IsDefined(Assembly, Type) IsDefined(Assembly, Type) IsDefined(Assembly, Type)

确定是否将指定类型的任何自定义属性应用于指定的程序集。Indicates whether custom attributes of a specified type are applied to a specified assembly.

TryGetRawMetadata(Assembly, Byte*, Int32) TryGetRawMetadata(Assembly, Byte*, Int32) TryGetRawMetadata(Assembly, Byte*, Int32) TryGetRawMetadata(Assembly, Byte*, Int32)

安全性

InheritanceDemand
完全信任继承者。for full trust for inheritors. 此类不能由部分受信任的代码继承。This class cannot be inherited by partially trusted code.

适用于

线程安全性

此类型是线程安全的。This type is thread safe.

另请参阅