当链接从.NET 4.0应用程序,一个.NET 2.0托管组件,框架用吗? [英] When linking a .NET 2.0 Managed Assembly from a .NET 4.0 Application, which framework is used?

查看:110
本文介绍了当链接从.NET 4.0应用程序,一个.NET 2.0托管组件,框架用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个2.0 CLR程序集(纯管理code,没有混合模式的问题),我需要从一个4.0 CLR应用程序链接到,确实在2.0 CLR或4.0的2.0 code运行。

If I have a 2.0 CLR assembly (pure managed code, no mixed mode issues) that I need to link to from a 4.0 CLR Application, does the 2.0 code run on the 2.0 CLR or 4.0.

基本上,有4.0影响2.0 code重大更改任何风险?

Basically, is there any risk of 4.0 breaking changes affecting the 2.0 code?

推荐答案

以上答案是不正确。你得到并排完整的框架。一个.NET 2应用(请注意这意味着EXE,而不是库)将不会自动提升到.NET 4中。

The answer above is incorrect. You do get side by side with the full frameworks. A .Net 2 APPLICATION (note that means EXE, not library) will not auto promote to .Net 4.

但是,如果一个.NET 4.0的应用程序加载它加载到同一个运行时的.Net 2组件(否则他们怎么能共享信息)。在.NET 2集加载到使用应该尽量减少变化(主要是在.NET 4中的安全性变化)。

But if a .Net 4 application loads a .Net 2 assembly it is loaded into the same runtime (otherwise how could they share information). The .Net 2 assembly is loaded into the .net 4 runtime using a compatibility mode that is supposed to minimize breakage in changes (mostly for security changes in .Net 4).

与.NET 2组件不能引用一个.NET 4的组件,因为它不会具备的功能。

A .Net 2 assembly cannot reference a .Net 4 assembly because it would not have features.

的唯一的例外,我知道的是,如果你从C ++应用程序加载.NET程序集。在C ++应用程序可以加载和主机两种运行时。它可以有一个.net 2组件和.NET 4的组件加载,但他们不能直接互相交谈。这是CLR过程在SQL Server中是如何工作的。你可以有一个净2 CLR PROC和.NET 4.0 CLR PROC不沟​​通,但在服务器上加载双方

The ONLY exception to this that I know of is if you load a .Net assembly from a C++ app. The C++ application can load and host two runtimes. It could have a .Net 2 assembly and a .Net 4 assembly loaded, but they would not be able to talk to each other directly. This is how CLR Procs work in SQL Server. You can have a .Net 2 CLR Proc and a .Net 4 CLR Proc that do not communicate, but are both loaded on the server.

有在MSDN杂志一大篇关于最近举办的.Net框架,但我找不到它了。也许别人可以张贴链接。

There was a great article on MSDN Magazine about hosting the .Net framework recently, but I can't find it now. Maybe someone else can post the link.

所以,你应该能够只加载任何净2组装成一个.NET 4中的可执行文件没有太大的问题。我见过的唯一的问题是用安全权限。

So you should be able to load just about any .Net 2 assembly into a .Net 4 executable without much problem. The only problems I have seen are with security permissions.

这篇关于当链接从.NET 4.0应用程序,一个.NET 2.0托管组件,框架用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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