为什么增加提及项目面向.NET Framework 4.0中会失败? [英] Why does adding a reference to project targeting .NET Framework 4.0 fail?

查看:136
本文介绍了为什么增加提及项目面向.NET Framework 4.0中会失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两个项目都是类库。项目1是VS 2008项目和面向.NET Framework 3.5。项目2是VS 2010(发布候选)项目,该项目面向.NET Framework 4.0。当我尝试将引用添加到项目2项目1项,它失败,比错误提示信息较少。我知道,如果我的目标框架项目2更改为3.5,然后加入引用会工作。我的问题是,如果我不改变目标框架,但转化项目1至VS 2010,将在引用的工作?换句话说,有没有针对不同的framework版本类库之间的一些固有incompatiblity,或者是失败对我来说,因为VS 2008不知道的4.0框架?

We have two projects that are both class libraries. Project 1 is a VS 2008 project and targets the .NET Framework 3.5. Project 2 is a VS 2010 (release candidate) project that targets the .NET Framework 4.0. When I try to add a reference to Project 2 in Project 1, it fails with a less than informative error message. I know that if I change the target Framework for Project 2 to 3.5, then adding the reference will work. My question is, if I don't change the target frameworks, but convert Project 1 to VS 2010, will the referencing work? Stated another way, is there some inherent incompatiblity between class libraries targeting different framework versions, or is it failing for me because VS 2008 doesn't know about the 4.0 framework?

推荐答案

是的,这是一个问题。就像你不能从.NET 1.0或1.1项目中添加引用到.NET 2.0的程序集。在.NET 4.0是一个新的运行的版本的框架(CLR)中。在.NET 3.5和3.0版本都使用2.0的运行的版本的框架(CLR)的。

Yes it is a problem. Much like you can't add a reference to a .NET 2.0 assembly from a .NET 1.0 or 1.1 project. The .NET 4.0 is a new runtime version of the framework (CLR). The .NET 3.5 and 3.0 releases both use the 2.0 runtime version of the framework (CLR).

您可以随时添加,从建有一个较新的运行时程序集的引用程序集与旧的运行,而不是周围的其他方式。

You can always add a reference from an assembly built with a newer runtime to an assembly with an older runtime, but not the other way around.

这是.NET 2.0(3.0和3.5):
*可以参考.NET 2.0(3.0和3.5)组件
*不能引用.NET 4.0组件

From .NET 2.0 (3.0 and 3.5):
* Can reference .NET 2.0 (3.0 and 3.5) assemblies
* Can NOT reference .NET 4.0 assemblies

这是.NET 4.0:
*可以参考.NET 4.0组件
*可以参考.NET 2.0(3.0和3.5)组件

From .NET 4.0:
* Can reference .NET 4.0 assemblies
* Can reference .NET 2.0 (3.0 and 3.5) assemblies

这篇关于为什么增加提及项目面向.NET Framework 4.0中会失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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