You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System.Reflection/Assembly.xml
+16-21Lines changed: 16 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -4041,7 +4041,11 @@ This property is marked obsolete starting in .NET 5, and generates a compile-tim
4041
4041
<format type="text/markdown">< configuration element.
4044
+
<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.
4045
+
4046
+
**.NET Framework only:** 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.
4047
+
4048
+
In .NET Core/5+, the `assemblyRef` can be either a local or remote assembly. [Code Access Security (CAS)](/dotnet/core/porting/net-framework-tech-unavailable#code-access-security-cas) is not supported and it is up to the caller to avoid loading remote assemblies if desired.
4045
4049
4046
4050
> [!NOTE]
4047
4051
> Do not use an <xref:System.Reflection.AssemblyName> with only the <xref:System.Reflection.AssemblyName.CodeBase%2A> property set. The <xref:System.Reflection.AssemblyName.CodeBase%2A> property does not supply any elements of the assembly identity (such as name or version), so loading does not occur according to load-by-identity rules, as you would expect from the <xref:System.Reflection.Assembly.Load%2A> method. Instead, the assembly is loaded using load-from rules. For information about the disadvantages of using the load-from context, see the <xref:System.Reflection.Assembly.LoadFrom%2A?displayProperty=nameWithType> method overload or [Best Practices for Assembly Loading](/dotnet/framework/deployment/best-practices-for-assembly-loading).
@@ -4064,11 +4068,6 @@ This property is marked obsolete starting in .NET 5, and generates a compile-tim
<paramref name="assemblyRef" /> is not found.</exception>
4066
4070
<exception cref="T:System.IO.FileLoadException">A file that was found could not be loaded.
4067
-
4068
-
-or-
4069
-
4070
-
<paramref name="assemblyRef" /> specifies a remote assembly, but the ability to execute code in remote assemblies is disabled. See <see href="https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/runtime/loadfromremotesources-element"><loadFromRemoteSources></see>.
4071
-
4072
4071
Note: In <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Windows Store apps</see> or the <see href="https://docs.microsoft.com/dotnet/standard/cross-platform/cross-platform-development-with-the-portable-class-library">Portable Class Library</see>, catch the base class exception, <see cref="T:System.IO.IOException" />, instead.
@@ -4626,17 +4625,15 @@ The assembly is loaded using the supplied evidence. The raw bytes representing t
4626
4625
## Remarks
4627
4626
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.
4628
4627
4629
-
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.
4628
+
**.NET Framework only:** 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.
4629
+
4630
+
In .NET Core/5+, the `path` can be either a local or remote location. [Code Access Security (CAS)](/dotnet/core/porting/net-framework-tech-unavailable#code-access-security-cas) is not supported and it is up to the caller to avoid loading from a remote location if desired.
4630
4631
4631
4632
]]></format>
4632
4633
</remarks>
4633
4634
<exception cref="T:System.ArgumentException">The <paramref name="path" /> argument is not an absolute path.</exception>
4634
4635
<exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is <see langword="null" />.</exception>
4635
-
<exception cref="T:System.IO.FileLoadException">A file that was found could not be loaded.
4636
-
4637
-
-or-
4638
-
4639
-
The ability to execute code in remote assemblies is disabled. See <see href="https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/runtime/loadfromremotesources-element"><loadFromRemoteSources></see>. </exception>
4636
+
<exception cref="T:System.IO.FileLoadException">A file that was found could not be loaded.</exception>
4640
4637
<exception cref="T:System.IO.FileNotFoundException">The <paramref name="path" /> parameter is an empty string ("") or does not exist.</exception>
<paramref name="path" /> is not a valid assembly for the currently loaded runtime.
@@ -4801,20 +4798,18 @@ Starting with .NET Framework 4, the ability to execute code in assemblies loaded
4801
4798
4802
4799
`assemblyFile` may be absolute or relative to the current directory.
4803
4800
4804
-
Assemblies can be loaded into one of three contexts, or can be loaded without context:
4801
+
**.NET Framework only:** Assemblies can be loaded into one of three contexts, or can be loaded without context:
4805
4802
4806
4803
- The load context contains assemblies found by probing: in the GAC, in a host assembly store if the runtime is hosted, or in the <xref:System.AppDomainSetup.ApplicationBase%2A> and <xref:System.AppDomainSetup.PrivateBinPath%2A> of the application domain. Most overloads of the <xref:System.Reflection.Assembly.Load%2A> method load assemblies into this context.
4807
4804
4808
-
- The load-from context contains assemblies for which the user provided a path not included in the directories searched by probing. <xref:System.Reflection.Assembly.LoadFrom%2A>, <xref:System.AppDomain.CreateInstanceFrom%2A>, and <xref:System.AppDomain.ExecuteAssembly%2A> are examples of methods that load by path.
4805
+
- The load-from context contains assemblies for which the user provided a path not included in the directories searched by probing. It also allows dependencies on that path to be found and loaded because the path information is maintained by the context. <xref:System.Reflection.Assembly.LoadFrom%2A>, <xref:System.AppDomain.CreateInstanceFrom%2A>, and <xref:System.AppDomain.ExecuteAssembly%2A> are examples of methods that load by path.
4809
4806
4810
4807
Starting with .NET Framework 4, if the URI of `assemblyFile` specifies a remote location, assembly loading is disabled by default, and the `LoadFrom` 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.
4811
4808
4812
4809
- The reflection-only context contains assemblies loaded with the <xref:System.Reflection.Assembly.ReflectionOnlyLoad%2A> and <xref:System.Reflection.Assembly.ReflectionOnlyLoadFrom%2A> methods; code in these contexts cannot be executed.
4813
4810
4814
4811
- If the user generated or found the assembly, it is not in any context. This applies to assemblies loaded using overloads of the <xref:System.Reflection.Assembly.Load%2A> method that specify a byte array containing an assembly, and to transient dynamic assemblies created with reflection emit and not saved to disk.
4815
4812
4816
-
The load-from context allows an assembly to be loaded from a path not included in probing, and yet allows dependencies on that path to be found and loaded because the path information is maintained by the context.
4817
-
4818
4813
The <xref:System.Reflection.Assembly.LoadFrom%2A> method has the following disadvantages. Consider using <xref:System.Reflection.Assembly.Load%2A> instead.
4819
4814
4820
4815
- If an assembly with the same identity is already loaded in the load-from context, <xref:System.Reflection.Assembly.LoadFrom%2A> returns the loaded assembly even if a different path was specified.
@@ -4846,11 +4841,7 @@ Starting with .NET Framework 4, the ability to execute code in assemblies loaded
4846
4841
<paramref name="assemblyFile" /> is <see langword="null" />.</exception>
<paramref name="assemblyFile" /> is not found, or the module you are trying to load does not specify a filename extension.</exception>
4849
-
<exception cref="T:System.IO.FileLoadException">A file that was found could not be loaded.
4850
-
4851
-
-or-
4852
-
4853
-
The ability to execute code in remote assemblies is disabled. See <see href="https://docs.microsoft.com/dotnet/framework/configure-apps/file-schema/runtime/loadfromremotesources-element"><loadFromRemoteSources></see>. </exception>
4844
+
<exception cref="T:System.IO.FileLoadException">A file that was found could not be loaded.</exception>
<paramref name="assemblyFile" /> is not a valid assembly for the currently loaded runtime; for example, a 32-bit assembly in a 64-bit process.
4856
4847
</exception>
@@ -5045,6 +5036,9 @@ The ability to execute code in remote assemblies is disabled. See <see href="htt
5045
5036
<format type="text/markdown"><![CDATA[
5046
5037
5047
5038
## Remarks
5039
+
5040
+
In .NET Core and .NET 5+, this method throws <xref:System.NotSupportedException> when called. Use <xref:System.Reflection.Assembly.LoadFrom%28System.String%29> instead.
5041
+
5048
5042
The `assemblyFile` parameter must refer to a URI without escape characters. This method supplies escape characters for all invalid characters in the URI.
5049
5043
5050
5044
> [!NOTE]
@@ -5082,6 +5076,7 @@ The ability to execute code in remote assemblies is disabled. See <see href="htt
5082
5076
5083
5077
]]></format>
5084
5078
</remarks>
5079
+
<exception cref="T:System.NotSupportedException">.NET Core and .NET 5+ only: In all cases.</exception>
5085
5080
<exception cref="T:System.ArgumentNullException">
5086
5081
<paramref name="assemblyFile" /> is <see langword="null" />.</exception>
0 commit comments