我最近使用Entity Framework 5开发了一个.net 4.5库.一切正常,直到我被告知我必须降级到.net 4.0才能与
Windows 2003保持兼容.
我使用程序包管理器控制台卸载了EF 5并获得了成功的消息,然后这个消息:
Failed to generate binding redirects for 'MyProjectName'. An item with the same key has already been added.
降级和安装Entity Framework后会出现相同的消息.
一切都在编译.但是在执行时我有这个例外:
The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception. 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)":"EntityFramework,PublicKeyToken=b77a5c561934e089"
在Web.Config(以及库的App.Config)中,我有以下几行:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,PublicKeyToken=b77a5c561934e089" requirePermission="false"/> ... <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime>
任何帮助,将不胜感激.
解决方法
由于另一个话题,我终于解决了这个问题:
could-not-load-file-or-assembly-entityframework-after-downgrading-ef-5-0-0-0
尽管我使用Package Manager Console安装了EF 5软件包. .Net 4.0的实体框架的实际版本是4.4版.我已经改变了配置文件中的值,它确实有效!
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,Version=4.4.0.0,PublicKeyToken=b77a5c561934e089" requirePermission="false"/> ... <dependentAssembly> <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0"/> </dependentAssembly>
原文地址:https://www.jb51.cc/aspnet/245265.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。