我最近使用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, Version=5.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
在 Web.Config(以及库的 App.Config)中,我有以下内容:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, 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>
非常感谢您的帮助。