在 .NET 4.0 应用程序域上加载面向 .NET 4.5 的程序集 [英] Loading an assembly targeted for .NET 4.5 on a .NET 4.0 app domain

查看:34
本文介绍了在 .NET 4.0 应用程序域上加载面向 .NET 4.5 的程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设系统安装了 .NET 4.0 和 .NET 4.5.

Assuming the system has .NET 4.0 and .NET 4.5 installed.

是否可以从针对 .NET 4.0 编写的程序集加载和使用 .NET 4.5 程序集?

Is it possible to load and work with a .NET 4.5 assembly from an assembly written targeting .NET 4.0?

简单地说,我可以从 .NET 4.0 代码调用 Assembly.Load 来加载面向 .NET 4.5 的程序集吗?

Simply put, can I call Assembly.Load from .NET 4.0 code to load a .NET 4.5 targeting assembly?

推荐答案

假设系统为 .NET 4.0 和 .NET 4.5:

Assuming a system as .NET 4.0 and .NET 4.5:

marcgravell 的博客中所述 由 sehe 链接

As stated in marcgravell's blog linked by sehe

4.5 是 GAC 中 4.0 之上的就地安装;安装 4.5 后,4.0 将与 4.5 程序集一起运行

4.5 is an in-place over-the-top install on top of 4.0, in the GAC; once you have installed 4.5, 4.0 runs with the 4.5 assemblies

然后从面向 4.0 的 .NET 代码(由 4.0 编译器编译)调用 Assembly.Load,实际上将使用 4.5 框架实现运行,所以我看不出它无法加载 4.5 程序集的任何原因.

Then calling Assembly.Load from a .NET code targeting 4.0 (compiled by a 4.0 compiler), will actually run in using the 4.5 framework implementation, so I don't see any reason why it couldn't load a 4.5 assembly.

margravell 指出,当您尝试在仅安装 4.0 的系统上运行 .NET 4.5 编译代码时会出现问题,因为 yield return/break 迭代器的实现会导致缺少方法引用.但这不应该影响你.

margravell notes that problems occur when you try to run .NET 4.5 compiled code on a system with only 4.0 installed, as the implementation of the yield return/break iterators causes a missing method reference. But this shouldn't affect you.

这篇关于在 .NET 4.0 应用程序域上加载面向 .NET 4.5 的程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆