无法加载文件或程序集“EntityFramework,Version = 6.0.0.0, [英] Could not load file or assembly 'EntityFramework, Version=6.0.0.0,

查看:119
本文介绍了无法加载文件或程序集“EntityFramework,Version = 6.0.0.0,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与EF合作。
我试图执行这一行

  public ActionResult Edit(string id)
{
return View(obj.FindSemesterById(id));
}

我在我的项目中安装了EF版本5。



但是我收到这个错误:


无法加载文件或程序集EntityFramework,Version = 6.0.0.0 ,
Culture = neutral,
PublicKeyToken = b77a5c561934e089或其依赖关系之一。定位的程序集的
清单定义与程序集引用不匹配。 (HRESULT的异常:
0x80131040)


我的web.config文件:

 <?xml version =1.0encoding =utf-8?> 
<! -
有关如何配置ASP.NET应用程序的更多信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
- >
< configuration>
< configSections>
<! - 有关实体框架配置的更多信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - >
< section name =entityFrameworktype =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version = 5.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089requirePermission =false/> ;
< / configSections>
< connectionStrings>
< add name =EducationDBEntitiesconnectionString =metadata = res://*/EducationModel.csdl | res://*/EducationModel.ssdl | res://*/EducationModel.msl; provider = System .Data.SqlClient; provider connection string =& quot; data source =; initial catalog = EducationDB; integrated security = True; MultipleActiveResultSets = True; App = EntityFramework& quot; providerName =System.Data.EntityClient/>
< / connectionStrings>
< appSettings>
< add key =webpages:Versionvalue =2.0.0.0/>
< add key =webpages:Enabledvalue =false/>
< add key =PreserveLoginUrlvalue =true/>
< add key =ClientValidationEnabledvalue =true/>
< add key =UnobtrusiveJavaScriptEnabledvalue =true/>
< / appSettings>
< system.web>
< compilation debug =truetargetFramework =4.5/>
< httpRuntime targetFramework =4.5/>
< authentication mode =Forms>
< forms loginUrl =〜/ Account / Logintimeout =2880/>
< / authentication>
< pages>
< namespaces>
< add namespace =System.Web.Helpers/>
< add namespace =System.Web.Mvc/>
< add namespace =System.Web.Mvc.Ajax/>
< add namespace =System.Web.Mvc.Html/>
< add namespace =System.Web.Optimization/>
< add namespace =System.Web.Routing/>
< add namespace =System.Web.WebPages/>
< / namespaces>
< / pages>
< /system.web>
< system.webServer>
< validation validateIntegratedModeConfiguration =false/>
<处理程序>
< remove name =ExtensionlessUrlHandler-ISAPI-4.0_32bit/>
< remove name =ExtensionlessUrlHandler-ISAPI-4.0_64bit/>
< remove name =ExtensionlessUrlHandler-Integrated-4.0/>
< add name =ExtensionlessUrlHandler-ISAPI-4.0_32bitpath =*。 verb =GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONSmodules =IsapiModulescriptProcessor =%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dllpreCondition =classicMode,runtimeVersionv4.0,bitness32responseBufferLimit =0/>
< add name =ExtensionlessUrlHandler-ISAPI-4.0_64bitpath =*。 verb =GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONSmodules =IsapiModulescriptProcessor =%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dllpreCondition =classicMode,runtimeVersionv4.0,bitness64responseBufferLimit =0/>
< add name =ExtensionlessUrlHandler-Integrated-4.0path =*。动词=GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONStype =System.Web.Handlers.TransferRequestHandlerpreCondition =integratedMode,runtimeVersionv4.0/>
< / handlers>
< /system.webServer>
<运行时>
< assemblyBinding xmlns =urn:schemas-microsoft-com:asm.v1>
< dependentAssembly>
< assemblyIdentity name =System.Web.HelperspublicKeyToken =31bf3856ad364e35/>
< bindingRedirect oldVersion =1.0.0.0-2.0.0.0newVersion =2.0.0.0/>
< / dependentAssembly>
< dependentAssembly>
< assemblyIdentity name =System.Web.MvcpublicKeyToken =31bf3856ad364e35/>
< bindingRedirect oldVersion =1.0.0.0-4.0.0.0newVersion =4.0.0.0/>
< / dependentAssembly>
< dependentAssembly>
< assemblyIdentity name =System.Web.WebPagespublicKeyToken =31bf3856ad364e35/>
< bindingRedirect oldVersion =1.0.0.0-2.0.0.0newVersion =2.0.0.0/>
< / dependentAssembly>

< / assemblyBinding>

< / runtime>
< entityFramework>
< defaultConnectionFactory type =System.Data.Entity.Infrastructure.LocalDbConnectionFactory,EntityFramework>
< parameters>
< parameter value =v11.0/>
< / parameters>
< / defaultConnectionFactory>
< / entityFramework>
< / configuration>


解决方案

从评论部分看来,能够从公共NuGet源安装最新版本的EF,因为您的计算机没有直接访问互联网,无法解析 www.nuget.org 。通常情况下,如果您在互联网设置中配置代理,Visual Studio将在从公共存储库安装NuGet时使用此代理。



所以一旦安装了最新的 EF 6.1.0 包,错误就会消失。目前,您似乎正在使用一些较旧版本的软件包,并且您的解决方案中有项目需要v6。


I am working with EF . I am trying to execute this line

public ActionResult Edit(string id)
{           
     return View(obj.FindSemesterById(id));
}

I installed EF Version 5 on my project.

But i get this error :

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)

My web.config file :

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="EducationDBEntities" connectionString="metadata=res://*/EducationModel.csdl|res://*/EducationModel.ssdl|res://*/EducationModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=EducationDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>

    </assemblyBinding>

  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

解决方案

From the comments section it appears that you weren't able to install the latest version of EF from the public NuGet source because your computer didn't have direct access to the internet and was unable to resolve the www.nuget.org domain. Normally if you configure a proxy in your internet settings, Visual Studio will use this proxy when installing a NuGet from the public repository.

So once you have installed the latest EF 6.1.0 package in your project, the error will go away. Currently you seem to be using some older version of the package and you have projects in your solution that require v6.

这篇关于无法加载文件或程序集“EntityFramework,Version = 6.0.0.0,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆