Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法加载文件或程序集';实体框架&x27;或者它的一个依赖项_C#_.net_Asp.net Mvc 3_Entity Framework - Fatal编程技术网

C# 无法加载文件或程序集';实体框架&x27;或者它的一个依赖项

C# 无法加载文件或程序集';实体框架&x27;或者它的一个依赖项,c#,.net,asp.net-mvc-3,entity-framework,C#,.net,Asp.net Mvc 3,Entity Framework,我在IIS上有此错误,但在本地主机站点上工作正常 无法加载文件或程序集“EntityFramework”或其依赖项之一。此程序集由比当前加载的运行时更新的运行时生成,因此无法加载 堆栈跟踪: [BadImageFormatException: Could not load file or assembly 'EntityFramework' or one of its dependencies. This assembly is built by a runtime newer than the

我在IIS上有此错误,但在本地主机站点上工作正常

无法加载文件或程序集“EntityFramework”或其依赖项之一。此程序集由比当前加载的运行时更新的运行时生成,因此无法加载

堆栈跟踪:

[BadImageFormatException: Could not load file or assembly 'EntityFramework' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'EntityFramework' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54
   System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +232
   System.Web.Compilation.BuildManager.CompileGlobalAsax() +52
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +337

[HttpException (0x80004005): Could not load file or assembly 'EntityFramework' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
   System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729

[HttpException (0x80004005): Could not load file or assembly 'EntityFramework' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8894031
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +333

请帮助检查该网站的IISPool,并使其使用最新版本的.Net。这将解决您的问题

请参见下面的快照


@user1545035-然后将其标记为答案!Jigar给出了帮助UAL的答案。尽管这可能会解决问题,但它没有回答引发此异常的原因。我有一个类似的例子,但是没有一个引用程序集使用EntityFramework,那么到底为什么会抛出这个异常呢?这毫无意义,除非整个IIS团队都建立了依赖关系,支持使用.NET Framework 4,然后又会出现其他奇怪的行为,例如要求引用Microsoft.Web.Infrastructure.dll,尽管没有使用MCV。这只是IIS团队缓慢的工作。时期