为什么我的 .NET 4.5 项目不能使用为 .NET 4 编译的 DLL?(均使用 EF 5) [英] Why can't my .NET 4.5 project use a DLL compiled for .NET 4? (Both use EF 5)

查看:26
本文介绍了为什么我的 .NET 4.5 项目不能使用为 .NET 4 编译的 DLL?(均使用 EF 5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由客户端应用程序和 WebApi 网站组成的应用程序.

I have an application that consists of a client-side application and a WebApi website.

我的客户端目标是 .NET 4,这样我就不必坚持让用户安装 .NET 4.5.但是,我的网站完全在我的控制之下,所以我的目标是 .NET 4.5.

My client-side stuff is targetting .NET 4 so that I don't have to insist that users install .NET 4.5. My website, however, is entirely under my control, so I'm targetting .NET 4.5.

有一个共享程序集,用于数据访问.它使用实体框架 5.

There is one shared assembly, which I use for data access. It uses Entity Framework 5.

当我构建客户端应用程序时,使用的 DLL 是版本 4.4.xxx,而当我构建 Web 应用程序时,使用的 DLL 是 5.0.xxx.

When I build the client application, the DLL used is version 4.4.xxx, whereas when I build the web application, the DLL is 5.0.xxx.

到目前为止,我已经能够毫无问题地运行客户端应用程序,而且我也能够再次毫无问题地运行 Web 应用程序.

Up until now, I've been able to run the client application with no problems, and I've also been able to run the web application, again without problems.

但是,我现在从头开始重新创建了我的 Web 应用程序项目 (*),突然我无法运行它.在首次调用我的数据访问程序集时,我收到一条 YSOD,提示无法加载文件或程序集 'EntityFramework,版本 = 4.4.0.0 ...".

However, I've now re-created my web application project from scratch (*), and suddenly I can't run it. I get a YSOD saying "Could not load file or assembly 'EntityFramework, Version=4.4.0.0 ..." at the point where my data-access assembly is first invoked.

现在,该错误的含义非常清楚 - 它找不到数据访问程序集使用的 v4.4 DLL - 但我不明白为什么我的新项目会出现这个问题'我的旧项目有问题.据我所知,每个项目中都引用了相同的 DLL.

Now, it's perfectly clear what that error means - it can't find the v4.4 DLL as used by the data-access assembly - but I don't understand why that's a problem with my new project when it wasn't a problem with my old project. As far as I can see, the same DLLs are referenced in each project.

(*) 我应该解释为什么我要重新创建我的项目.我最初是在VS 2012 RC中创建的项目,后来升级到了release版本.尽管这应该升级了我的项目,但我遇到了一些问题,并且还注意到与新创建的项目存在一些差异.所以,为了安全起见 - 希望能规避那些其他问题 - 我正在从头开始重新创建它.

(*) I should explain why I'm re-creating my project. I originally created the project in VS 2012 RC, and then later upgraded to the release version. Although this supposedly upgraded my project, I've had a few problems with it, and have also noticed some differences v. a newly-created project. So, to be on the safe side - and hopefully circumvent those other problems - I'm re-creating it from scratch.

那么,我的问题是:为什么会突然出现问题,我该怎么做才能解决?

So, my question: why is this suddenly a problem, and what can I do to resolve it?

推荐答案

依赖于程序集的代码是否设置为需要确切版本?如果是这样,您将需要 EntityFramework 程序集的发布者政策或<引用应用程序(网络项目)的 href="http://msdn.microsoft.com/en-us/library/eftw1fys.aspx" rel="nofollow">bindingRedirect.

Is the code depending on the assemblies set to require the exact version? If so, you will need a publisher policy for the EntityFramework assembly or bindingRedirect for the referencing application (web project).

这篇关于为什么我的 .NET 4.5 项目不能使用为 .NET 4 编译的 DLL?(均使用 EF 5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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