简体   繁体   English

为什么.net 4.0项目不能引用4.5程序集?

[英]Why cant a .net 4.0 project reference a 4.5 assembly?

I am working on a project targeting .NET 4.0 and now I need to reference a third party dll which was built targeting .NET 4.5. 我正在开发一个针对.NET 4.0的项目,现在我需要引用一个针对.NET 4.5构建的第三方dll。 It seems that visual studio does not accept that? 似乎visual studio不接受这个? Why? 为什么? VS shows me that dll name does not exist in current context. VS告诉我当前上下文中不存在dll名称。

Because you are referencing to the higher version. 因为您引用了更高版本。 Microsoft can be backcompatible, but not "future compatible". 微软可以兼容,但不兼容“未来兼容”。 You need to convert your entire project to higher vesion, in order to be able to use that binary. 您需要将整个项目转换为更高版本,以便能够使用该二进制文件。

Don't know what tecnology you are talking about exactly, but if that asp.net , consider that in vNext you are able to deploy your own version of the cloud clr on the server. 不知道你正在谈论什么技术,但如果是asp.net ,请考虑在vNext中你可以在服务器上部署自己的cloud clr版本。 So you may have 2 versions of your app, one targetting 4.5 , other 4.0 . 所以你可能有2个版本的应用程序,一个目标4.5 ,其他4.0

Introducing vNext . 介绍vNext Repeat, if this concerns you. 重复,如果这涉及到你。

A project targeting .NET 4.0 can run on the 4.0 runtime. 面向.NET 4.0的项目可以在4.0运行时运行。 A DLL targeting .NET 4.5 cannot. 一个针对.NET 4.5的DLL不能。

If allowed; 如果允许的话; you would be able to build projects that appear to work in 4.0, and fail when they tried to load the 4.5 components. 您将能够构建似乎在4.0中工作的项目,并在尝试加载4.5组件时失败。

You can reference things going the other way; 你可以参考另一种方式; as a 4.0 DLL can be loaded in the 4.5 runtime. 因为4.0 DLL可以在4.5运行时加载。

You will need to either request a 4.0 version of the DLL from the third party; 您需要从第三方请求4.0版本的DLL; or target .NET 4.5. 或目标.NET 4.5。

The application domain will be running under the 4.0 runtime and so cannot reference newer dotnet version, only the reverse is true. 应用程序域将在4.0运行时下运行,因此无法引用较新的dotnet版本,只有相反的情况才是真的。

4.5 is a different .net runtime so it is not possible to load a 4.5 in an older version. 4.5是一个不同的.net运行时,因此无法在旧版本中加载4.5。

You must remember that the runtime will need to interpret the Intermediate Language (IL) into machine code. 您必须记住,运行时需要将中间语言(IL)解释为机器代码。 If the IL was created on 4.5 a 4.0 runtime would have no idea how to interpret it. 如果IL是在4.5上创建的,那么4.0运行时将不知道如何解释它。

Create a console app in 4.5 and then execute a cmd from 4.0 to get the data you needed from 4.5, might be a quick solution. 在4.5中创建一个控制台应用程序,然后从4.0执行cmd以从4.5获取所需的数据,这可能是一个快速的解决方案。 Not idea but it does the job :) 不知道,但它做的工作:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以在面向 4.0 的项目中引用面向 .net 4.5 的程序集? - Is it possible to reference an assembly that targets .net 4.5 in a project that targets 4.0? 在 4.0 项目中引用 .net framework 4.5.1 程序集 - Reference a .net framework 4.5.1 assembly in a 4.0 project 在 .NET 4.0 应用程序域上加载面向 .NET 4.5 的程序集 - Loading an assembly targeted for .NET 4.5 on a .NET 4.0 app domain 为什么我在安装VS2012 / .Net 4.5后在.Net 4.0 Assembly.GetCustomAttributes上得到ExecutionEngineException? - Why am I getting ExecutionEngineException on .Net 4.0 Assembly.GetCustomAttributes after installing VS2012/.Net 4.5? XmlSerializer空引用异常出现在.NET 4.0中,但没有出现在.NET 4.5中 - XmlSerializer null reference exception appears in .NET 4.0 but not in .NET 4.5 .NET 4.5程序集可以引用.NET 4.0程序集吗? - Can .NET 4.5 assemblies reference .NET 4.0 assemblies? 在 .NET 4.0 项目中引用 .NET 2.0 混合模式程序集需要什么“附加配置”? - What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project? 将应用程序从.NET 4.5重新指向4.0后的参考错误 - Reference error after repointing application from .NET 4.5 to 4.0 EDMX .NET 4.5到4.0? - EDMX .NET 4.5 to 4.0? 将.NET项目从4.5转换为4.0的最简单方法? - easiest way to convert .NET project from 4.5 to 4.0?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM