是否在.NET框架的旧版本使用汇编编译影响到整体性能比较? [英] Does using assembly compiled in older version of .NET framework affects whole perfomance?

查看:138
本文介绍了是否在.NET框架的旧版本使用汇编编译影响到整体性能比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们想象一下,我们有两个组件:

Lets imagine that we have two assemblies:

  1. Foo.Logic
  2. (在.NET 2.0框架编译)
  3. Foo.Application(编译在.NET 4.0框架)具有参考和使用编译Foo.Logic。
  1. Foo.Logic (compiled on .NET 2.0 framework)
  2. Foo.Application (compiled on .NET 4.0 framework) that have reference and uses compiled Foo.Logic.

是否有Foo.Application性能的影响(或有任何其他缺点)?

Does it have impact on Foo.Application performance (or have any other drawbacks)?

推荐答案

在你的问题中描述的情况来看,一切都只是工作™没有任何问题。

In the situation you described in the question, everything will Just Work™ without any problems.

一个.NET 4.0应用程序将直接加载.NET 2.0库到.NET 4.0运行时环境。它不会使用并排端执行,除非您明确要求它。有很多误传,或在关于这个各地的网络不清的语句,所以要小心评估你读。

A .NET 4.0 application will load a .NET 2.0 library directly into the .NET 4.0 runtime environment. It will not use side-by-side execution unless you explicitly ask it to. There's a lot of misinformation or unclear statements made about this around the web, so be careful in evaluating what you read.

这篇文章,这证实了乔恩斯基特说,在他的回答。特别是,文章解释(强调):

I finally came across this article, which confirms what Jon Skeet says in his answer. In particular, the article explains (emphasis added):

在进程内的SxS没有解决所面临的库开发的兼容性问题。 按应用直接加载任何的库 - 无论是通过直接引用或的Assembly.Load - 将继续直接加载到应用程序加载它的运行和应用程序域。这意味着,如果一个应用程序被重新编译针对.NET Framework 4的运行时间运行,并仍具有内置在.NET 2.0相关的组件,这些家属将加载在.NET 4运行时也是如此。因此,我们仍然建议测试你的库对你想支持的框架的所有版本,[S]。这是我们继续保持我们的高向后兼容性的水平的原因之一。

In-Proc SxS does not solve the compatibility problems faced by library developers. Any libraries directly loaded by an application--either via a direct reference or an Assembly.Load--will continue to load directly into the runtime and AppDomain of the application loading it. This means that if an application is recompiled to run against the .NET Framework 4 runtime and still has dependent assemblies built against .NET 2.0, those dependents will load on the .NET 4 runtime as well. Therefore, we still recommend testing your libraries against all version[s] of the framework you wish to support. This is one of the reasons we have continued to maintain our high level of backward compatibility.

但是,如果你有兴趣,甚至更多的具体细节,这是值得一提的是与4.0版的CLR引入的新功能之一是在同一时间从运行多个版本的运行能力在一个单一的过程。这就是所谓的在过程的一个侧面并排执行(或进程内的SxS如果你非常酷),是一个非常有力的工具。你可以阅读更多关于它的<一个href="http://blogs.msdn.com/b/clrteam/archive/2009/06/03/in-process-side-by-side-part1.aspx">here在CLR团队的博客。

But if you're interested in even more of the nitty-gritty details, it's worth mentioning that one of the new features introduced with version 4.0 of the CLR is the ability to run multiple versions of the runtime at the same time from in a single process. This is called "In Process Side-by-Side Execution" (or "Inproc SxS" if you're very cool), and is a very powerful tool. You can read more about it here on the CLR team's blog.

下面是一些pretty的图片演示的目的:

Here are some pretty pictures for demonstration purposes:

请注意这是用来构建.NET 3.0和3.5版本上的.NET 2.0上方的千层饼模式。这意味着,他们将所有的运行并排侧没有任何问题。但是,其它版本的隔离的将会的创建问题。

Note the "layer-cake" model that was used to build the .NET 3.0 and 3.5 releases on top of .NET 2.0. That means that they'll all run side-by-side without any problems. But the isolation of the other versions will create a problem.

然而,如上所述,.NET 4.0解决了这个问题侧面并排执行:

However, as mentioned above, .NET 4.0 solves this problem with Side-by-Side Execution:

,这主要适用于涉及COM和互操作与外部应用程序如Outlook的情况下,但它仍然是一个非常酷的功能。

Of course, this is mostly applicable to situations involving COM and interop with external applications like Outlook, but it's still a very cool feature.

但无论哪种方式,你应该看不到任何的任何问题,这种方法,无论是与兼容性,性能,或者其他。

But either way, you shouldn't see any problems whatsoever with this approach, either with compatibility, performance, or whatever else.

这篇关于是否在.NET框架的旧版本使用汇编编译影响到整体性能比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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