Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions xml/System.Reflection/Assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4041,6 +4041,9 @@ This property is marked obsolete starting in .NET 5, and generates a compile-tim
<format type="text/markdown"><![CDATA[

## Remarks

In .NET Core 2.0 and later, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.

<xref:System.IO.FileLoadException> is thrown if `assemblyRef` specifies the full assembly name and the first assembly that matches the simple name has a different version, culture, or public key token. The loader does not continue probing for other assemblies that match the simple name. Starting with .NET Framework 4, because execution of code in remote assemblies is disabled by default, a <xref:System.IO.FileLoadException> is also thrown if `assemblyRef` specifies a remote assembly. To enable execution of code loaded from remote locations, you can use the [`<loadFromRemoteSources>`](/dotnet/framework/configure-apps/file-schema/runtime/loadfromremotesources-element) configuration element.

> [!NOTE]
Expand Down Expand Up @@ -4132,6 +4135,9 @@ Note: In <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Win
<format type="text/markdown"><![CDATA[

## Remarks

In .NET Core 2.0 and later, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.

To load the correct assembly, it's recommended to call the `Load` method by passing the long form of the assembly name. The long form of an assembly name consists of its simple name (such as "System" for the System.dll assembly) along with its version, culture, public key token, and optionally its processor architecture. It corresponds to the assembly's <xref:System.Reflection.Assembly.FullName%2A> property. The following example illustrates the use of a long name to load the System.dll assembly for the .NET Framework 4:

:::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/Load/load11.cs" id="Snippet1":::
Expand Down Expand Up @@ -4236,6 +4242,8 @@ To load the correct assembly, it's recommended to call the `Load` method by pass

## Remarks

In .NET Core 2.0 and later, the target assembly will be loaded into the current <xref:System.Runtime.Loader.AssemblyLoadContext>. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.

This method overload always creates a new <xref:System.Reflection.Assembly> object in its own isolated load context.

**.NET Framework only:** The trust level of an assembly that is loaded by using this method is the same as the trust level of the calling assembly. To load an assembly from a byte array with the trust level of the application domain, use the <xref:System.Reflection.Assembly.Load%28System.Byte%5B%5D%2CSystem.Byte%5B%5D%2CSystem.Security.SecurityContextSource%29> method overload. For more information about the use of evidence with overloads of the <xref:System.Reflection.Assembly.Load%2A> method that take byte arrays, see the <xref:System.Reflection.Assembly.Load%28System.Byte%5B%5D%2CSystem.Byte%5B%5D%2CSystem.Security.Policy.Evidence%29> method overload.
Expand Down Expand Up @@ -4624,6 +4632,11 @@ The assembly is loaded using the supplied evidence. The raw bytes representing t
<format type="text/markdown"><![CDATA[

## Remarks

This API is present in .NET Core for compatibility, but it is recommended to use <xref:System.Runtime.Loader.AssemblyLoadContext> overloads in .NET Core 2.0 and later.

The assembly is loaded into a new AssemblyLoadContext created for this purpose. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.

Use the <xref:System.Reflection.Assembly.LoadFile%2A> method to load and examine assemblies that have the same identity, but are located in different paths. <xref:System.Reflection.Assembly.LoadFile%2A> does not load files into the load-from context, and does not resolve dependencies using the load path, as the <xref:System.Reflection.Assembly.LoadFrom%2A> method does. <xref:System.Reflection.Assembly.LoadFile%2A> is useful in this limited scenario because <xref:System.Reflection.Assembly.LoadFrom%2A> cannot be used to load assemblies that have the same identities but different paths; it will load only the first such assembly.

Starting with .NET Framework 4, if `path` specifies an assembly in a remote location, assembly loading is disabled by default, and the `LoadFile` method throws a <xref:System.IO.FileLoadException>. To enable execution of code loaded from remote locations, you can use the [`<loadFromRemoteSources>`](/dotnet/framework/configure-apps/file-schema/runtime/loadfromremotesources-element) configuration element.
Expand Down Expand Up @@ -4794,8 +4807,15 @@ Starting with .NET Framework 4, the ability to execute code in assemblies loaded
<format type="text/markdown"><![CDATA[

## Remarks

This API is present in .NET Core for compatibility, but it is recommended to use <xref:System.Runtime.Loader.AssemblyLoadContext> overloads in .NET Core 2.0 and later.

The assembly is loaded into the default AssemblyLoadContext. For more information on assembly loading, see <see cref="https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/loading-managed#algorithm" />.

The `assemblyFile` parameter must refer to a URI without escape characters. This method supplies escape characters for all invalid characters in the URI.

Before .NET 5, the following applied:

> [!NOTE]
> File transfer protocol (FTP) is not supported. If the URI supplied for `assemblyFile` is an FTP address, the assembly is not loaded. No exception is thrown.

Expand Down Expand Up @@ -5045,6 +5065,11 @@ The ability to execute code in remote assemblies is disabled. See <see href="htt
<format type="text/markdown"><![CDATA[

## Remarks

This API is not supported in .NET Core 2.0 or later. It will always throw <xref:System.NotSupportedException>.

The assembly is loaded into the default AssemblyLoadContext.

The `assemblyFile` parameter must refer to a URI without escape characters. This method supplies escape characters for all invalid characters in the URI.

> [!NOTE]
Expand Down