gpt4 book ai didi

c# - 为什么 Silverlight 5 Assembly.LoadFrom 声明为内部?

转载 作者:行者123 更新时间:2023-11-30 13:04:15 24 4
gpt4 key购买 nike

  • 长长的叹息 * 再次像爱丽丝一样,我发现自己又一次掉进了兔子洞。又名 Microsoft 决策者。

我应该提一下,我从未安装过 SL5 测试版。我一直等到实际发布后很久。在安装官方 v5 版本之前。

因此,使用 Telerik JustDecompile(.NET Reflector 的替代品)我加载了休闲 SL 程序集,为了彻底起见,我也加入了 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

在 WP7 System.Reflection.Assembly 中包含休闲方法......

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

在 SL3 System.Reflection.Assembly 中包含休闲方法......

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);

在 SL4 System.Reflection.Assembly 中包含休闲方法......

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);

在 SL5 System.Reflection.Assembly 中包含休闲方法......

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);

现在我不得不问到底发生了什么?!? SL5 中的 Load 和 LoadFrom 已更改为内部!为什么?我问是因为在我的代码中的各个地方我都使用 LoadFrom 从磁盘加载程序集。我的代码最初是为 XNA 3 编写的,然后移植到 XNA 4,然后移植到 SL4,但是当我更新到 SL5 时,LoadFrom 不再可用。为什么某个功能在最近 2 个或更多版本中可用,却在 SL5 中隐藏

我已经在 Silverlight 论坛上发布了这个问题,但没有任何回应,而且 SL5 的新增功能和更改内容文档似乎也没有提及。

最佳答案

来自non-silverlight MSDN article

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

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

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

If an assembly is loaded with LoadFrom, and the probing path includes an assembly with the same identity but a different location, an InvalidCastException, MissingMethodException, or other unexpected behavior can occur.

LoadFrom demands FileIOPermissionAccess.Read and FileIOPermissionAccess.PathDiscovery, or WebPermission, on the specified path.

If a native image exists for assemblyFile, it is not used. The assembly cannot be loaded as domain neutral.

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

一段时间以来,不使用 LoadFrom 一直是个好习惯。我怀疑这只是这种做法的形式化。

关于c# - 为什么 Silverlight 5 Assembly.LoadFrom 声明为内部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9878489/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com