我安装了 EF6,然后意识到 MySQL 尚未在其连接器/网络上为其提供支持。所以很自然地我回滚了,现在我得到了标题中引用的错误。
我的 app.config 看起来像这样
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
我的引用资料如下:
名称: EntityFramework.dll
创建者: Microsoft Corporation
版本: 5.0.20627.0
此外,我还引用了以下程序集:
名称:System.Data
版本:4.0.0.0
文件版本:4.030319.17929
名称:System.Data.Entity
版本:4.0.0.0
文件版本:4.030319.17929
我得到的异常的确切文本是:
An error occurred creating the configuration section handler for entityFramework: Could not load file or assembly 'EntityFramework, Version=4.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 版本 5.0.0.0 dll。所以只需尝试替换以下代码行即可。
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
关于c# - 如何修复异常无法加载文件或程序集 'EntityFramework, Version=4.0.0.0[...]' 或其依赖项之一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19721167/