Επεξεργασία

Κοινή χρήση μέσω


Assembly.UnsafeLoadFrom(String) Method

Definition

Loads an assembly into the load-from context, bypassing some security checks.

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

Parameters

assemblyFile
String

The name or path of the file that contains the manifest of the assembly.

Returns

The loaded assembly.

Attributes

Exceptions

assemblyFile is null.

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 is not a valid assembly for the currently loaded runtime.

A codebase that does not start with "file://" was specified without the required WebPermission.

The assemblyFile parameter is an empty string ("").

The assembly name exceeds the system-defined maximum length.

Remarks

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). Before the .NET Framework 4, such assemblies were automatically loaded into a sandboxed application domain. Starting with the .NET Framework 4, they are loaded with full trust.

As an alternative to using this method, you can apply the <NetFx40_LegacySecurityPolicy> Element in your application configuration file. This causes the common language runtime to revert to the security policy of the .NET Framework 3.5.

Caution

If you use either of these solutions, you must be certain that it is safe to load assemblyFile with full trust.

For a discussion of load contexts, including the load-from context, see the LoadFrom(String) method overload.

Applies to