c# - 无法加载文件或程序集 'EntityFramework,版本 = 6.0.0.0

标签 c# asp.net .net entity-framework visual-studio

我做错了什么?我该如何解决这个问题?

我有一个包含多个项目的解决方案。它是一个 MVC .NET 4.5 Web 应用程序。

当我在 Debug模式下启动后调用其中一个项目时,出现此错误。

导致此错误的项目具有以下引用:

enter image description here

都是6.0.0.0

版本

“/”应用程序中的服务器错误。 无法加载文件或程序集“EntityFramework,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”或其依赖项之一。找到的程序集的 list 定义与程序集引用不匹配。 (HRESULT 异常:0x80131040) 说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=6.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)

Source Error:


Line 139:        public vvvRepository() {
Line 140:            this._vvvEntities = new vvvEntities();
Line 141:        }
Line 142:
Line 143:        public vvvRepository(int commandTimeout) {


Source File: c:\tfs\PACE\eee Framework\branches\1.23\eeeService\Adapters\vvv\eeeService.vvv.DataAccess\vvvRepository.cs    Line: 141

Assembly Load Trace: The following information can be helpful to determine why the assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' could not be loaded.


=== Pre-bind state information ===
LOG: User = eee\ksmith
LOG: DisplayName = EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 (Fully-specified)
LOG: Appbase = file:///C:/tfs/PACE/eee Framework/branches/1.23/eeeService/vvvWebProd/zzz/zzz/
LOG: Initial PrivatePath = C:\tfs\PACE\eee Framework\branches\1.23\eeeService\vvvWebProd\zzz\zzz\bin
Calling assembly : eeeService.vvv.DataAccess, Version=1.22.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\tfs\PACE\eee Framework\branches\1.23\eeeService\vvvWebProd\zzz\zzz\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
LOG: Attempting download of new URL file:///C:/Users/ksmith/AppData/Local/Temp/Temporary ASP.NET Files/root/1993f739/49fe9ab6/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/Users/ksmith/AppData/Local/Temp/Temporary ASP.NET Files/root/1993f739/49fe9ab6/EntityFramework/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/tfs/PACE/eee Framework/branches/1.23/eeeService/vvvWebProd/zzz/zzz/bin/EntityFramework.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.


Stack Trace:


[FileLoadException: Could not load file or assembly 'EntityFramework, Version=6.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)]
   eeeService.vvv.DataAccess.vvvRepository..ctor() in c:\tfs\PACE\eee Framework\branches\1.23\eeeService\Adapters\vvv\eeeService.vvv.DataAccess\vvvRepository.cs:141
   ttt.ttt.get_Repository() in c:\tfs\PACE\eee Framework\branches\1.23\eeeService\vvvWebProd\zzz\ttt\ttt.cs:21
   ttt.ttt.GetDeviceBySerialNumber(String serialNumber) in c:\tfs\PACE\eee Framework\branches\1.23\eeeService\vvvWebProd\zzz\ttt\ttt.cs:52
   eee.EnterpriseServices.eeeFramework.zzz.Controllers.SettingsController.lookupDeviceForSettingsPost(String serialnumber) in c:\tfs\PACE\eee Framework\branches\1.23\eeeService\vvvWebProd\zzz\zzz\Controllers\SettingsController.cs:364
   lambda_method(Closure , ControllerBase , Object[] ) +180
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +59
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +435
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +60
   System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +50
   System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +75
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +44
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +73
   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +126
   System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +323
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +44
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +74
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +68
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +184
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +136
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +66
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +40
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +68
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +65
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +45
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +66
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9628700
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18044 

这里是抛出异常的项目的app.config文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b761934e089" requirePermission="false" />
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b761934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b761934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.0.0" />
      </dependentAssembly>

    </assemblyBinding>
  </runtime>
<system.serviceModel>
    <bindings>
      <wsHttpBinding>
      </wsHttpBinding>
    </bindings>

  </system.serviceModel></configuration>

我做错了什么?我该如何解决这个问题?

最佳答案

Main 项目可能引用了旧版本的 Entity Framework,因此旧的 dll 在构建中。确保所有使用问题项目的项目都有新的引用

关于c# - 无法加载文件或程序集 'EntityFramework,版本 = 6.0.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32705371/

相关文章:

c# - 8.10 azure 部署错误 : ts-loader: Using typescript@1.

c# - 如何在 C# 中返回 Min 谓词中的对象?

c# - 从 C# 上的 linq 获取 JSON 数组

asp.net - .CSHTML 页面不会呈现

asp.net - AppHarbor: 目录 '/App_GlobalResources/' 不允许,因为应用程序是预编译的

c# - 部署到Minikube时出现ErrImageNeverPull

c# - Json RestSharp 反序列化响应数据 null

c# - 段落列表不包含完整内容

c# - 在 .NET 4 中实现 RegEx 超时

c# - 我可以使用 Windows 窗体控件的多个副本吗?