Assembly.UnsafeLoadFrom(String) Assembly.UnsafeLoadFrom(String) Assembly.UnsafeLoadFrom(String) Assembly.UnsafeLoadFrom(String) Method


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

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


String String String String

包含程序集清单的文件的名称或路径。The name or path of the file that contains the manifest of the assembly.


加载的程序集。The loaded assembly.


未找到 assemblyFile,或者你正在试图加载的模块未指定文件名扩展。assemblyFile is not found, or the module you are trying to load does not specify a filename extension.

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

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

- 或 --or- assemblyFile 使用高于当前所加载版本的公共语言运行时版本编译而成。assemblyFile was compiled with a later version of the common language runtime than the version that is currently loaded.

指定了不以“file://”开头的基本代码,且没有所需的 WebPermissionA codebase that does not start with "file://" was specified without the required WebPermission.

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

程序集名称超过系统定义的最大长度。The assembly name exceeds the system-defined maximum length.


使用此方法加载操作系统已标记为已加载从 Web (例如,从 Internet 或 intranet 下载的临时文件) 的本地程序集。Use this method to load a local assembly that the operating system has flagged as having been loaded from the Web (for example, a temporary file that was downloaded from the Internet or intranet). 之前.NET Framework 4.NET Framework 4,此类程序集都要自动加载到沙盒应用程序域。Before the .NET Framework 4.NET Framework 4, such assemblies were automatically loaded into a sandboxed application domain. 从开始.NET Framework 4.NET Framework 4,它们是以完全信任方式加载的。Starting with the .NET Framework 4.NET Framework 4, they are loaded with full trust.

作为使用此方法的替代方法,可以将应用 <NetFx40_LegacySecurityPolicy>元素应用程序配置文件中。As an alternative to using this method, you can apply the <NetFx40_LegacySecurityPolicy> Element in your application configuration file. 这会导致公共语言运行时,若要还原到的安全策略 .NET Framework 3.5.NET Framework 3.5This causes the common language runtime to revert to the security policy of the .NET Framework 3.5.NET Framework 3.5.


如果您使用这些解决方案,你必须是确定它是否可以安全地加载assemblyFile以完全信任。If you use either of these solutions, you must be certain that it is safe to load assemblyFile with full trust.

有关讨论加载上下文,包括加载位置上下文,请参阅LoadFrom(String)方法重载。For a discussion of load contexts, including the load-from context, see the LoadFrom(String) method overload.


直接调用方需要完全信任。requires full trust for the immediate caller. 不能由部分受信任的或透明的代码使用此成员。This member cannot be used by partially trusted or transparent code.