语言

Assembly.Load 方法

定义

加载程序集。

重载

名称 说明
Load(Byte[], Byte[], SecurityContextSource)

使用基于通用对象文件格式(COFF)的图像加载程序集,其中包含发出的程序集,可以选择包括符号并指定安全上下文的源。

Load(Byte[], Byte[], Evidence)
已过时.

使用基于通用对象文件格式(COFF)的图像加载程序集,其中包含所发出的程序集(可选)包括程序集的符号和证据。

Load(String, Evidence)
已过时.

加载给定程序集的显示名称并使用提供的证据。

Load(AssemblyName, Evidence)
已过时.

在给定程序集的给定的情况下 AssemblyName加载程序集。 使用提供的证据加载程序集。

Load(Byte[])

使用基于公共对象文件格式(COFF)的图像加载程序集,其中包含发出的程序集。

Load(String)

加载具有指定名称的程序集。

Load(AssemblyName)

在给定程序集的给定的情况下 AssemblyName加载程序集。

Load(Byte[], Byte[])

使用基于通用对象文件格式(COFF)的图像加载程序集,其中包含所发出的程序集(可选)包括程序集的符号。

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

使用基于通用对象文件格式(COFF)的图像加载程序集,其中包含发出的程序集,可以选择包括符号并指定安全上下文的源。

public:
 static System::Reflection::Assembly ^ Load(cli::array <System::Byte> ^ rawAssembly, cli::array <System::Byte> ^ rawSymbolStore, System::Security::SecurityContextSource securityContextSource);
public static System.Reflection.Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore, System.Security.SecurityContextSource securityContextSource);
static member Load : byte[] * byte[] * System.Security.SecurityContextSource -> System.Reflection.Assembly
Public Shared Function Load (rawAssembly As Byte(), rawSymbolStore As Byte(), securityContextSource As SecurityContextSource) As Assembly

参数

rawAssembly
Byte[]

一个字节数组,它是基于 COFF 的映像,其中包含发出的程序集。

rawSymbolStore
Byte[]

包含表示程序集符号的原始字节的字节数组。

securityContextSource
SecurityContextSource

安全上下文的源。

返回

加载的程序集。

例外

rawAssembly 是 null。

rawAssembly 不是当前加载的运行时的有效程序集。

值 securityContextSource 不是枚举值之一。

注解

程序集使用安全上下文的指定源加载到调用方的应用程序域中。 如果 rawSymbolStore 已指定,则还会加载表示程序集符号的原始字节。

适用于

Load(Byte[], Byte[], Evidence)

注意

This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

使用基于通用对象文件格式(COFF)的图像加载程序集,其中包含所发出的程序集(可选)包括程序集的符号和证据。

public:
 static System::Reflection::Assembly ^ Load(cli::array <System::Byte> ^ rawAssembly, cli::array <System::Byte> ^ rawSymbolStore, System::Security::Policy::Evidence ^ securityEvidence);
public static System.Reflection.Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore, System.Security.Policy.Evidence securityEvidence);
[System.Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public static System.Reflection.Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore, System.Security.Policy.Evidence securityEvidence);
static member Load : byte[] * byte[] * System.Security.Policy.Evidence -> System.Reflection.Assembly
[<System.Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>]
static member Load : byte[] * byte[] * System.Security.Policy.Evidence -> System.Reflection.Assembly
Public Shared Function Load (rawAssembly As Byte(), rawSymbolStore As Byte(), securityEvidence As Evidence) As Assembly

参数

rawAssembly
Byte[]

一个字节数组,它是基于 COFF 的映像,其中包含发出的程序集。

rawSymbolStore
Byte[]

包含表示程序集符号的原始字节的字节数组。

securityEvidence
Evidence

加载程序集的证据。

返回

加载的程序集。

属性

例外

rawAssembly 是 null。

rawAssembly 不是当前加载的运行时的有效程序集。

程序集或模块加载了两次,其中包含两个不同的证据。

securityEvidence 不是 null。 默认情况下,.NET Framework 4 中未启用旧 CAS 策略;如果未启用, securityEvidence 则必须 null为 。

注解

此方法重载始终在其自己的独立负载上下文中创建一个新 Assembly 对象。

使用提供的证据加载程序集。 还将加载表示程序集符号的原始字节。

是否将特定的权限授予程序集是基于证据的。 程序集和安全证据合并的规则如下所示:

  • 在没有参数的情况下Load使用Evidence方法时,会加载程序集,并带有加载程序提供的证据。

  • 将 Load 方法与参数一 Evidence 起使用时,将合并一些证据。 作为参数提供的证据片段取代 Load 加载程序提供的证据片段。

  • 将 Load 方法重载与参数一起使用 Byte[] 来加载 COFF 映像时,证据将从调用程序集继承。

  • 将 Load 方法与参数一起使用 Byte[] 并 Evidence 加载 COFF 图像时,仅使用提供的证据。 将忽略调用程序集的证据和 COFF 映像的证据。

如果在同一程序集上多次调用 Load 该方法,但指定了不同的证据,则公共语言运行时不会引发该方法 FileLoadException ,因为无法确定不同证据规范的相等性和完整性。 首先成功的证据是使用的证据。

适用于

Load(String, Evidence)

注意

This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

加载给定程序集的显示名称并使用提供的证据。

public:
 static System::Reflection::Assembly ^ Load(System::String ^ assemblyString, System::Security::Policy::Evidence ^ assemblySecurity);
public static System.Reflection.Assembly Load(string assemblyString, System.Security.Policy.Evidence assemblySecurity);
[System.Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public static System.Reflection.Assembly Load(string assemblyString, System.Security.Policy.Evidence assemblySecurity);
static member Load : string * System.Security.Policy.Evidence -> System.Reflection.Assembly
[<System.Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>]
static member Load : string * System.Security.Policy.Evidence -> System.Reflection.Assembly
Public Shared Function Load (assemblyString As String, assemblySecurity As Evidence) As Assembly

参数

assemblyString
String

程序集的显示名称。

assemblySecurity
Evidence

加载程序集的证据。

返回

加载的程序集。

属性

例外

assemblyString 是 null。

找不到 assemblyString。

assemblyString 不是当前加载的运行时的有效程序集。

找不到的文件无法加载。

-或-

程序集或模块加载了两次,其中包含两个不同的证据。

注解

FileLoadException 如果 assemblyString 指定完整的程序集名称,并且与简单名称匹配的第一个程序集具有不同的版本、区域性或公钥标记,则引发 。 加载程序不会继续探测与简单名称匹配的其他程序集。

是否将特定的权限授予程序集是基于证据的。 程序集和安全证据合并的规则如下所示:

  • 在没有参数的情况下Load使用Evidence方法时,会加载程序集,并带有加载程序提供的证据。

  • 将 Load 方法与参数一 Evidence 起使用时,将合并一些证据。 作为参数提供的证据片段取代 Load 加载程序提供的证据片段。

  • 将 Load 方法重载与参数一起使用 Byte[] 以加载通用对象文件格式 (COFF) 图像时,证据将从调用程序集继承。

  • 将 Load 方法与参数一起使用 Byte[] 并 Evidence 加载 COFF 图像时,仅使用提供的证据。 将忽略调用程序集的证据和 COFF 映像的证据。

如果在同一程序集上多次调用此方法,但指定了不同的证据,则公共语言运行时不会引发此方法 FileLoadException ,因为无法确定不同证据规范的相等性和完整性。 首先成功的证据是使用的证据。

在 .NET Framework 版本 2.0 中,处理器体系结构将添加到程序集标识中,并且可以指定为程序集名称字符串的一部分。 例如,“ProcessorArchitecture=msil”。 但是,指定程序集名称的建议方法是创建对象 AssemblyName 并将其传递给方法的适当 Load 重载。 请参阅 AssemblyName.ProcessorArchitecture。

另请参阅

适用于

Load(AssemblyName, Evidence)

注意

This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.

在给定程序集的给定的情况下 AssemblyName加载程序集。 使用提供的证据加载程序集。

public:
 static System::Reflection::Assembly ^ Load(System::Reflection::AssemblyName ^ assemblyRef, System::Security::Policy::Evidence ^ assemblySecurity);
public static System.Reflection.Assembly Load(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity);
[System.Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")]
public static System.Reflection.Assembly Load(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity);
static member Load : System.Reflection.AssemblyName * System.Security.Policy.Evidence -> System.Reflection.Assembly
[<System.Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of Load which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")>]
static member Load : System.Reflection.AssemblyName * System.Security.Policy.Evidence -> System.Reflection.Assembly
Public Shared Function Load (assemblyRef As AssemblyName, assemblySecurity As Evidence) As Assembly

参数

assemblyRef
AssemblyName

描述要加载的程序集的对象。

assemblySecurity
Evidence

加载程序集的证据。

返回

加载的程序集。

属性

例外

assemblyRef 是 null。

找不到 assemblyRef。

assemblyRef 不是当前加载的运行时的有效程序集。

程序集或模块加载了两次,其中包含两个不同的证据。

-或-

assemblyRef 指定基于 <loadFromRemoteSources> 禁用的位置。

注解

FileLoadException 如果 assemblyRef 指定完整的程序集名称,并且与简单名称匹配的第一个程序集具有不同的版本、区域性或公钥标记,则引发 。 加载程序不会继续探测与简单名称匹配的其他程序集。

请参阅 <loadFromRemoteSources> 从远程位置加载程序集。

注释

不要仅AssemblyName对属性集使用CodeBase。 该 CodeBase 属性不提供程序集标识的任何元素(如名称或版本),因此加载不会根据按标识规则进行加载,正如方法预期 Load 的那样。 相反,程序集是使用从规则加载的。 有关使用从上下文加载的缺点的信息,请参阅Assembly.LoadFrom程序集加载的方法重载或最佳做法。

是否将特定的权限授予程序集是基于证据的。 程序集和安全证据合并的规则如下所示:

  • 在没有参数的情况下Load使用Evidence方法时,会加载程序集,并带有加载程序提供的证据。

  • 将 Load 方法与参数一 Evidence 起使用时,将合并一些证据。 作为参数提供的证据片段取代 Load 加载程序提供的证据片段。

  • 将 Load 方法重载与参数一起使用 Byte[] 以加载通用对象文件格式 (COFF) 图像时,证据将从调用程序集继承。

  • 将 Load 方法与参数一起使用 Byte[] 并 Evidence 加载 COFF 图像时,仅使用提供的证据。 将忽略调用程序集的证据和 COFF 映像的证据。

注释

AssemblyName.Name如果同时设置了属性和AssemblyName.CodeBase属性,则首次尝试加载程序集时使用显示名称(包括版本、区域性等),如属性返回)。Assembly.FullName 如果未找到该文件, CodeBase 则用于搜索程序集。 如果使用找到 CodeBase程序集,则显示名称与程序集匹配。 如果匹配失败,则会引发 a FileLoadException 。

如果在同一程序集上多次调用 Load 该方法,但指定了不同的证据,则公共语言运行时不会引发该方法 FileLoadException ,因为无法确定不同证据规范的相等性和完整性。 首先成功的证据是使用的证据。

另请参阅

适用于

Load(Byte[])

Source:
Assembly.cs
Source:
Assembly.cs
Source:
Assembly.cs
Source:
Assembly.cs
Source:
Assembly.cs

使用基于公共对象文件格式(COFF)的图像加载程序集,其中包含发出的程序集。

public:
 static System::Reflection::Assembly ^ Load(cli::array <System::Byte> ^ rawAssembly);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
public static System.Reflection.Assembly Load(byte[] rawAssembly);
public static System.Reflection.Assembly Load(byte[] rawAssembly);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")>]
static member Load : byte[] -> System.Reflection.Assembly
static member Load : byte[] -> System.Reflection.Assembly
Public Shared Function Load (rawAssembly As Byte()) As Assembly

参数

rawAssembly
Byte[]

一个字节数组,它是基于 COFF 的映像,其中包含发出的程序集。

返回

加载的程序集。

属性

例外

rawAssembly 是 null。

rawAssembly 不是当前加载的运行时的有效程序集。

注解

此方法重载始终在其自己的独立负载上下文中创建一个新 Assembly 对象。

仅限 .NET Framework: 使用此方法加载的程序集的信任级别与调用程序集的信任级别相同。 若要从具有应用程序域信任级别的字节数组加载程序集,请使用 Load(Byte[], Byte[], SecurityContextSource) 方法重载。 有关对采用字节数组的方法重载 Load 使用证据的详细信息,请参阅方法 Load(Byte[], Byte[], Evidence) 重载。

适用于

Load(String)

Source:
Assembly.CoreCLR.cs
Source:
Assembly.CoreCLR.cs
Source:
Assembly.CoreCLR.cs
Source:
Assembly.CoreCLR.cs
Source:
Assembly.CoreCLR.cs

加载具有指定名称的程序集。

public:
 static System::Reflection::Assembly ^ Load(System::String ^ assemblyString);
public static System.Reflection.Assembly Load(string assemblyString);
static member Load : string -> System.Reflection.Assembly
Public Shared Function Load (assemblyString As String) As Assembly

参数

assemblyString
String

程序集名称的长或短形式。

返回

加载的程序集。

例外

assemblyString 是 null。

assemblyString 是长度为零的字符串。

找不到 assemblyString。

找不到的文件无法加载。

assemblyString 不是当前加载的运行时的有效程序集。

示例

以下示例加载给定其完全限定名称的程序集,并列出指定程序集中包含的所有类型。 有关如何获取完全限定程序集名称的信息,请参阅 程序集名称。

using System;
using System.Reflection;

class Class1
{
    public static void Main()
    {
        // You must supply a valid fully qualified assembly name.
        Assembly SampleAssembly = Assembly.Load
            ("SampleAssembly, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3");
        // Display all the types contained in the specified assembly.
        foreach (Type oType in SampleAssembly.GetTypes()) {
            Console.WriteLine(oType.Name);
        }
    }
}
Imports System.Reflection

Class Class1
    Public Shared Sub Main()
        ' You must supply a valid fully qualified assembly name.
        Dim SampleAssembly As [Assembly] = _
            [Assembly].Load("SampleAssembly, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3")
        Dim oType As Type
        ' Display all the types contained in the specified assembly.
        For Each oType In SampleAssembly.GetTypes()
            Console.WriteLine(oType.Name)
        Next oType
    End Sub	'LoadSample
End Class

注解

在 .NET Core/.NET 5+ 中,目标程序集将加载到当前 AssemblyLoadContext 程序集或 AssemblyLoadContext.CurrentContextualReflectionContext 上下文中(如果已设置)。 有关程序集加载的详细信息,请参阅 托管程序集加载算法。

若要加载正确的程序集,建议通过传递程序集名称的长格式来调用 Load 该方法。 程序集名称的长形式由其简单名称(如 System.dll 程序集的“系统”)及其版本、区域性、公钥令牌及其处理器体系结构(可选)组成。 它对应于程序集 FullName 的属性。 以下示例演示如何使用长名称加载 .NET Framework 4 的 System.dll 程序集:

using System;
using System.Reflection;

public class Example
{
   public static void Main()
   {
      string longName = "system, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
      Assembly assem = Assembly.Load(longName);
      if (assem == null)
         Console.WriteLine("Unable to load assembly...");
      else
         Console.WriteLine(assem.FullName);
   }
}
// The example displays the following output:
//        system, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Imports System.Reflection

Module Example
   Public Sub Main()
      Dim longName As String = "system, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
      Dim assem As Assembly = Assembly.Load(longName)
      If assem Is Nothing Then
         Console.WriteLine("Unable to load assembly...")
      Else
         Console.WriteLine(assem.FullName)
      End If
   End Sub
End Module
' The example displays the following output:
'       system, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

FileLoadException 如果 assemblyString 指定完整的程序集名称,并且与简单名称匹配的第一个程序集具有不同的版本、区域性或公钥标记,则引发 。 加载程序不会继续探测与简单名称匹配的其他程序集。

在 .NET Framework 版本 2.0 中,处理器体系结构将添加到程序集标识中,并且可以指定为程序集名称字符串的一部分。 例如,“ProcessorArchitecture=msil”。 但是,指定程序集名称的建议方法是创建对象 AssemblyName 并将其传递给方法的适当 Load 重载。 请参阅 AssemblyName.ProcessorArchitecture。

另请参阅

适用于

Load(AssemblyName)

Source:
Assembly.CoreCLR.cs
Source:
Assembly.CoreCLR.cs
Source:
Assembly.CoreCLR.cs
Source:
Assembly.CoreCLR.cs
Source:
Assembly.CoreCLR.cs

在给定程序集的给定的情况下 AssemblyName加载程序集。

public:
 static System::Reflection::Assembly ^ Load(System::Reflection::AssemblyName ^ assemblyRef);
public static System.Reflection.Assembly Load(System.Reflection.AssemblyName assemblyRef);
static member Load : System.Reflection.AssemblyName -> System.Reflection.Assembly
Public Shared Function Load (assemblyRef As AssemblyName) As Assembly

参数

assemblyRef
AssemblyName

描述要加载的程序集的对象。

返回

加载的程序集。

例外

assemblyRef 是 null。

找不到 assemblyRef。

找不到的文件无法加载。

-或-

仅限 .NET Framework: assemblyRef 指定基于 <loadFromRemoteSources> 禁用的位置。

注意:在 Windows Store 应用的 .NET 或 Portable 类库中,请改为捕获基类异常,IOException。

assemblyRef 不是当前加载的运行时的有效程序集。

示例

以下示例实例化一个 AssemblyName 对象,并使用它来加载 sysglobal.dll 程序集。 然后,该示例显示程序集的公共类型的全名。

using System;
using System.Reflection;

public class Example
{
   public static void Main()
   {
      String fullName = "sysglobl, Version=4.0.0.0, Culture=neutral, " +
                        "PublicKeyToken=b03f5f7f11d50a3a, processor architecture=MSIL";
      var an = new AssemblyName(fullName);
      var assem = Assembly.Load(an);
      Console.WriteLine("Public types in assembly {0}:", assem.FullName);
      foreach (var t in assem.GetTypes())
         if (t.IsPublic)
            Console.WriteLine("   {0}", t.FullName);
   }
}
// The example displays the following output:
//   Public types in assembly sysglobl, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a:
//      System.Globalization.CultureAndRegionInfoBuilder
//      System.Globalization.CultureAndRegionModifiers
Imports System.Reflection

Module Example
   Public Sub Main()
      Dim fullName As String = "sysglobl, Version=4.0.0.0, Culture=neutral, " +
                               "PublicKeyToken=b03f5f7f11d50a3a, processor architecture=MSIL"
      Dim an As New AssemblyName(fullName)
      Dim assem As Assembly = Assembly.Load(an)
      Console.WriteLine("Public types in assembly {0}:", assem.FullName)
      For Each t As Type in assem.GetTypes()
         If t.IsPublic Then Console.WriteLine("   {0}", t.FullName)
      Next
   End Sub
End Module

' The example displays the following output:
'   Public types in assembly sysglobl, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a:
'      System.Globalization.CultureAndRegionInfoBuilder
'      System.Globalization.CultureAndRegionModifiers

注解

在 .NET Core/.NET 5+ 中,目标程序集将加载到当前 AssemblyLoadContext 程序集或 AssemblyLoadContext.CurrentContextualReflectionContext 上下文中(如果已设置)。 有关程序集加载的详细信息,请参阅 托管程序集加载算法。

注释

仅限 .NET Framework: 有关从远程位置加载程序集的信息,请参阅 <loadFromRemoteSources>。

注释

仅限 .NET Framework:不要仅AssemblyName对属性集使用CodeBase。 该 CodeBase 属性不提供程序集标识的任何元素(如名称或版本),因此加载不会根据按标识规则进行加载,正如方法预期 Load 的那样。 相反,程序集是使用从规则加载的。 有关使用从上下文加载的缺点的信息,请参阅Assembly.LoadFrom程序集加载的方法重载或最佳做法。

注释

仅限 .NET Framework:AssemblyName.Name如果同时设置了属性和AssemblyName.CodeBase属性,则首次尝试加载程序集时使用显示名称(包括版本、区域性等),如属性返回)。Assembly.FullName 如果未找到该文件, CodeBase 则用于搜索程序集。 如果使用找到 CodeBase程序集,则显示名称与程序集匹配。 如果匹配失败,则会引发 a FileLoadException 。

另请参阅

适用于

Load(Byte[], Byte[])

Source:
Assembly.cs
Source:
Assembly.cs
Source:
Assembly.cs
Source:
Assembly.cs
Source:
Assembly.cs

使用基于通用对象文件格式(COFF)的图像加载程序集,其中包含所发出的程序集(可选)包括程序集的符号。

public:
 static System::Reflection::Assembly ^ Load(cli::array <System::Byte> ^ rawAssembly, cli::array <System::Byte> ^ rawSymbolStore);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")]
public static System.Reflection.Assembly Load(byte[] rawAssembly, byte[]? rawSymbolStore);
public static System.Reflection.Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore);
public static System.Reflection.Assembly Load(byte[] rawAssembly, byte[]? rawSymbolStore);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")>]
static member Load : byte[] * byte[] -> System.Reflection.Assembly
static member Load : byte[] * byte[] -> System.Reflection.Assembly
Public Shared Function Load (rawAssembly As Byte(), rawSymbolStore As Byte()) As Assembly

参数

rawAssembly
Byte[]

一个字节数组,它是基于 COFF 的映像,其中包含发出的程序集。

rawSymbolStore
Byte[]

包含表示程序集符号的原始字节的字节数组。

返回

加载的程序集。

属性

例外

rawAssembly 是 null。

rawAssembly 不是当前加载的运行时的有效程序集。

注解

在 .NET Core/5+ 中,目标程序集加载到当前 AssemblyLoadContext程序集中。 有关程序集加载的详细信息,请参阅 托管程序集加载算法。

此方法重载始终在其自己的独立负载上下文中创建一个新 Assembly 对象。

仅限 .NET Framework: 使用此方法加载的程序集的信任级别与调用程序集的信任级别相同。 若要从具有应用程序域信任级别的字节数组加载程序集,请使用 Load(Byte[], Byte[], SecurityContextSource) 方法重载。 有关对采用字节数组的方法重载 Load 使用证据的详细信息,请参阅方法 Load(Byte[], Byte[], Evidence) 重载。

适用于