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

查看:123
本文介绍了在.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.5程序集。 NET 4.0?

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链接


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

然后调用Assembly.Load从.NET代码中定位到4.0(由一个4.0编译器),实际上将在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天全站免登陆