Skip to content

Commit efd985c

Browse files
authored
Assembly.LoadFrom (.NET Framework) behaviour clarifications (#7737)
1 parent a47340c commit efd985c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

xml/System.Reflection/Assembly.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4709,11 +4709,15 @@ Starting with .NET Framework 4, the ability to execute code in assemblies loaded
47094709

47104710
The <xref:System.Reflection.Assembly.LoadFrom%2A> method has the following disadvantages. Consider using <xref:System.Reflection.Assembly.Load%2A> instead.
47114711

4712-
- If an assembly with the same identity is already loaded, <xref:System.Reflection.Assembly.LoadFrom%2A> returns the loaded assembly even if a different path was specified.
4712+
- 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.
47134713

4714-
- If an assembly is loaded with <xref:System.Reflection.Assembly.LoadFrom%2A>, and later an assembly in the load context attempts to load the same assembly by display name, the load attempt fails. This can occur when an assembly is de-serialized.
4714+
- An assembly can be loaded in the load-from context even though an assembly with the same identity exists in the load context. Interoperability between the two assemblies will not work, leading to errors such as <xref:System.InvalidCastException>, <xref:System.MissingMethodException>, or other unexpected behavior.
47154715

4716-
- If an assembly is loaded with <xref:System.Reflection.Assembly.LoadFrom%2A>, and the probing path includes an assembly with the same identity but a different location, an <xref:System.InvalidCastException>, <xref:System.MissingMethodException>, or other unexpected behavior can occur.
4716+
- Calling <xref:System.Reflection.Assembly.LoadFrom%2A> with a location that's in the probing path will load the assembly in the load context and not in the load-from context.
4717+
4718+
- If an assembly file whose identity is goverened by a binding redirect policy is passed to <xref:System.Reflection.Assembly.LoadFrom%2A>, the policy will be applied and the assembly will be loaded from the probing path in the load context.
4719+
4720+
- If an assembly is loaded in the load-from context, and later an assembly in the load context attempts to load the same assembly by display name, the load attempt fails. This can occur when an assembly is deserialized.
47174721

47184722
- <xref:System.Reflection.Assembly.LoadFrom%2A> demands <xref:System.Security.Permissions.FileIOPermissionAccess.Read?displayProperty=nameWithType> and <xref:System.Security.Permissions.FileIOPermissionAccess.PathDiscovery?displayProperty=nameWithType>, or <xref:System.Net.WebPermission>, on the specified path.
47194723

0 commit comments

Comments
 (0)