升级EF 5.0.0.0后无法加载文件或程序集“EntityFramework” - > 4.3.1.0 [英] Could not load file or assembly 'EntityFramework' after downgrading EF 5.0.0.0 --> 4.3.1.0

查看:141
本文介绍了升级EF 5.0.0.0后无法加载文件或程序集“EntityFramework” - > 4.3.1.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果太过仓促升级到EF 5.0.0.0 RC,并且被Windows Azure(.NET 4.0及更低版本)部署的.NET 4.5项目困扰,我决定降级为EF 4.3.1.0。 p>

我不确定执行此类迁移的最佳方法,但我的策略是使用管理NuGet软件包来识别哪些项目引用软件包,从每个项目,安装更换并重新检查正确的项目。



不幸的是,在这样做之后,我的解决方案产生了标题FileLoadException。

 无法加载文件或程序集EntityFramework,Version = 5.0.0.0,Culture = neutral,
PublicKeyToken = b77a5c561934e089或其一个依赖项。定位的程序集的
清单定义与程序集引用不匹配。 (HRESULT的异常:0x80131040)

我通过解决方案文件特别是packages.config搜索了引用EF 5.0.0.0 RC但是找不到。

解决方案

在repository.config和其他地方找到对EntityFramework的引用失败后,我在Web.config中引用了一个引用,因为我正在编辑它,以帮助我的诊断。



bindingRedirect引用的5.0.0.0不再安装,这似乎是异常的来源。老实说,我没有添加对Web.config的引用,在尝试在单独的项目中复制错误后,发现它不会被NuGet软件包安装程序添加,所以我不知道为什么它在那里,但是添加了一些东西

 < dependentAssembly> 
< assemblyIdentity name =EntityFrameworkpublicKeyToken =b77a5c561934e089culture =neutral/>
< bindingRedirect oldVersion =0.0.0.0-5.0.0.0newVersion =5.0.0.0/>
< / dependentAssembly>

我决定将此替换为工作项目中的等效元素。请注意,5.0.0.0的引用将替换为以下4.3.1.0:

 < dependentAssembly> 
< assemblyIdentity name =EntityFrameworkpublicKeyToken =b77a5c561934e089culture =neutral/>
< bindingRedirect oldVersion =0.0.0.0-4.3.1.0newVersion =4.3.1.0/>
< / dependentAssembly>

这个工作!



然后我决定删除EntityFramework的dependentAssembly引用。



它仍然工作!



所以,我在这里发布一个自我回答的问题希望它能帮助别人。如果有人可以向我解释:




  • 将EntityFramework的dependentAssembly添加到我的Web.config

  • 删除这些引用的任何后果



我会有兴趣学习。


After too hastily upgrading to EF 5.0.0.0 RC and being stuck with a .NET 4.5 project that wouldn't deploy to Windows Azure (.NET 4.0 and below), I decided to downgrade to EF 4.3.1.0.

I'm unsure of the best way to perform this type of migration but my strategy is to use "Manage NuGet Packages" identify which projects reference the package, uncheck the package from each project, install the replacement and recheck the correct projects.

Unfortunately, after doing this, my solution produced the titular "FileLoadException".

Could not load file or assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral,        
PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's 
manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I searched through the solution files particularly packages.config for references to EF 5.0.0.0 RC but could find none.

解决方案

After failed attempts to find references to EntityFramework in repositories.config and elsewhere, I stumbled upon a reference in Web.config as I was editing it to help with my diagnosis.

The bindingRedirect referenced 5.0.0.0 which was no longer installed and this appeared to be the source of the exception. Honestly, I did not add this reference to Web.config and, after trying to duplicate the error in a separate project, discovered that it is not added by the NuGet package installer so, I don't know why it was there but something added it.

<dependentAssembly>
  <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>

I decided to replace this with the equivalent element from a working project. NB the references to 5.0.0.0 are replaced with 4.3.1.0 in the following:

<dependentAssembly>
  <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>

This worked!

I then decided to remove the dependentAssembly reference for the EntityFramework in its entirety.

It still worked!

So, I'm posting this here as a self-answered question in the hope that it helps someone else. If anyone can explain to me:

  • What added the dependentAssembly for EntityFramework to my Web.config
  • Any consequence(s) of removing these references

I'd be interested to learn.

这篇关于升级EF 5.0.0.0后无法加载文件或程序集“EntityFramework” - &gt; 4.3.1.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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