繁体   English   中英

无法加载文件或程序集'EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'

[英]Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

我是ASP .NET MVC的新手。 我尝试使用Entity Framework,但是由于没有找到EF,所以它掉了下来。 我搜索了一个解决方案,并在另一篇文章中说我必须更改版本。 我做到了,但是没有成功。

Web.config文件:

  <configSections>
    <!-- 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.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <!--<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-SportsStore.WebUI-20150201211232;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-SportsStore.WebUI-20150201211232.mdf" />-->
    <!--<add name="EFDbContext" providerName="System.Data.SqlClient" connectionString="Data Source=(localDb)\v11.0;Initial Catalog=SportsStore;Integrated Security=True" />-->
    <add name="EFDbContext" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-SportsStore.WebUI-20150201211232;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-SportsStore.WebUI-20150201211232.mdf" />
  </connectionStrings>

那是来自浏览器的错误。

“ /”应用程序中的服务器错误。

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)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

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 11:     public class EFProductRepository : IProductsRepository
Line 12:     {
Line 13:         private EFDbContext context = new EFDbContext();
Line 14: 
Line 15:         public IQueryable<Product> Products {

Source File: c:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.Domain\Concrete\EFProductRepository.cs    Line: 13 

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 = rubenPC\ruben
LOG: DisplayName = EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 (Fully-specified)
LOG: Appbase = file:///C:/Users/ruben/Documents/Visual Studio 2012/Projects/SportsStore/SportsStore.WebUI/
LOG: Initial PrivatePath = C:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.WebUI\bin
Calling assembly : SportsStore.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.WebUI\web.config
LOG: Using host configuration file: C:\Users\ruben\Documents\IISExpress\config\aspnet.config
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/ruben/AppData/Local/Temp/Temporary ASP.NET Files/vs/400ee849/decd1b79/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/Users/ruben/AppData/Local/Temp/Temporary ASP.NET Files/vs/400ee849/decd1b79/EntityFramework/EntityFramework.DLL.
LOG: Attempting download of new URL file:///C:/Users/ruben/Documents/Visual Studio 2012/Projects/SportsStore/SportsStore.WebUI/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)]
   SportsStore.Domain.Concrete.EFProductRepository..ctor() in c:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.Domain\Concrete\EFProductRepository.cs:13
   DynamicInjectorf437813e479848489e7ebb4769e5ef53(Object[] ) +70
   Ninject.Activation.Providers.StandardProvider.Create(IContext context) +884
   Ninject.Activation.Context.ResolveInternal(Object scope) +218
   Ninject.Activation.Context.Resolve() +277
   Ninject.<>c__DisplayClass15.<Resolve>b__f(IBinding binding) +86
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
   System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +4078797
   Ninject.Planning.Targets.Target`1.GetValue(Type service, IContext parent) +169
   Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) +747
   Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) +269
   Ninject.Activation.Providers.<>c__DisplayClass4.<Create>b__2(ITarget target) +69
   System.Linq.WhereSelectArrayIterator`2.MoveNext() +66
   System.Linq.Buffer`1..ctor(IEnumerable`1 source) +216
   System.Linq.Enumerable.ToArray(IEnumerable`1 source) +77
   Ninject.Activation.Providers.StandardProvider.Create(IContext context) +847
   Ninject.Activation.Context.ResolveInternal(Object scope) +218
   Ninject.Activation.Context.Resolve() +277
   Ninject.<>c__DisplayClass15.<Resolve>b__f(IBinding binding) +86
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
   System.Linq.Enumerable.Single(IEnumerable`1 source) +191
   Ninject.ResolutionExtensions.Get(IResolutionRoot root, Type service, IParameter[] parameters) +70
   SportsStore.WebUI.Infrastructure.NinjectControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) in c:\Users\ruben\Documents\Visual Studio 2012\Projects\SportsStore\SportsStore.WebUI\Infrastructure\NinjectControllerFactory.cs:27
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +197
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +49
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

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

这就是代码的中断:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsStore.Domain.Abstract;
using SportsStore.Domain.Entities;

namespace SportsStore.Domain.Concrete
{
    public class EFProductRepository : IProductsRepository
    {
        private EFDbContext context = new EFDbContext();

        public IQueryable<Product> Products {
            get { return context.Products; }
        }
    }
}

EFDbContext.cs类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsStore.Domain.Entities;
using System.Data.Entity;

namespace SportsStore.Domain.Concrete
{
    public class EFDbContext : DbContext
    {
        public DbSet<Product> Products { get; set; }
    }
}

打开

Toos > Nuget Package Manager > Package Manager Console

然后跑

install-package entityframework -version 6.0.0.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集“EntityFramework.SqlServer,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089” 无法加载文件或程序集“系统,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”或其依赖项之一 FileNotFoundException-无法加载文件或程序集&#39;System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089&#39; 无法加载文件或程序集“System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”或其依赖项之一 无法加载文件或程序集&#39;System.Data.Linq,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089&#39;或其依赖项之一 如何解决无法从程序集 &#39;mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#39; 加载类型 &#39;System.ValueTuple`3&#39;? 来自程序集“mscorlib,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”的“System.Security.Principal.WindowsImpersonationContext” 应该引用模块&#39;System.Data.Linq&#39;Version = 4.0.0.0,Culture = neutral,Publickeytoken = b77a5c561934e089&#39; &#39;System.Security.Permissions.SecurityPermission,mscorlib,版本 = 4.0.0.0,文化 = 中性,PublicKeyToken = b77a5c561934e089&#39; 失败 程序集“System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”中的类型“System.Data.DataRow”未标记为可序列化
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM