Why is Silverlight 5 Assembly.LoadFrom declared internal?

  • Long elongated sigh * Again, like Alice, I again find myself in a rabbit hole. AKA Microsoft decision makers.

I should mention that I never installed a beta version of SL5. I waited a long time after the actual release. Before installing the official v5 release.

So, using Telerik JustDecompile (a replacement for .NET Reflector), I downloaded the assembled SL assemblies and just for the sake of thoroughness I also introduced WP7 ...

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\mscorlib.dll C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\mscorlib.dll C:\Program Files (x86)\Microsoft Silverlight\5.0.61118.0\mscorlib.dll C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone\mscorlib.dll 

In WP7, System.Reflection.Assembly contains processing methods ...

 public static Assembly Load(string assemblyString); public static Assembly LoadFrom(string assemblyFile); 

The SL3 System.Reflection.Assembly contains processing methods ...

 public static Assembly Load(string assemblyString); public static Assembly Load(byte[] rawAssembly); public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore); public static Assembly LoadFrom(string assemblyFile); 

The SL4 System.Reflection.Assembly contains processing methods ...

 public static Assembly Load(string assemblyString); public static Assembly Load(byte[] rawAssembly); public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore); public static Assembly LoadFrom(string assemblyFile); 

The SL5 System.Reflection.Assembly contains processing methods ...

 public static Assembly Load(string assemblyString); internal static Assembly Load(byte[] rawAssembly); internal static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore); internal static Assembly LoadFrom(string assemblyFile); 

Now I have to ask what happens on the check?!? Load and LoadFrom in SL5 changed to internal! What for? I ask because in different places, although from my code I use LoadFrom to load the assembly from disk. My code was originally written for XNA 3, then ported to XNA 4, then to SL4, but as I upgrade to SL5, LoadFrom is no longer available. Why should a feature be available for the last two or more versions, only to be hidden in SL5?

I posted this question on the Silverlight unanswered and SL5 forums, what's new and what has changed the docs don't seem to mention it.

+4
source share
1 answer

From an article other than Silverlight MSDN

The LoadFrom method has the following disadvantages. Consider using Download instead.

If an assembly with the same identifier is already loaded, LoadFrom returns the loaded assembly, even if a different path is specified.

If the assembly is loaded by LoadFrom, and later the assembly in the load context tries to load the same assembly by the display name, the load attempt fails. This can happen when the assembly is de-serialized.

If the assembly is loaded with LoadFrom and the discovery path includes the assembly with the same identifier, but in a different place, an InvalidCastException, MissingMethodException, or other unexpected behavior may occur.

LoadFrom requires FileIOPermissionAccess.Read and FileIOPermissionAccess.PathDiscovery, or WebPermission, to the specified path.

If an assembly image has its own image, it is not used. assembly cannot be loaded as a neutral area.

In the .NET Framework versions 1.0 and 1.1, the policy is not applied.

It has been a good practice for some time not to use LoadFrom. I suspect that this is just a formalization of this practice.

0
source

Source: https://habr.com/ru/post/1403525/


All Articles