EF Downgraded: Could not load file or assembly 'EntityFramework' or one of its dependencies

0

I have been getting the error below and for heavens sake I cannot figure out why. I have not made any changes except for upgrading to windows 10. I have downgraded my EF and upgraded to make sure I have the same version but that did not resolve. I have tried all options, did self host the application but even that did not help eliminating Visual Studio issues.

Would appreciate any suggestions please.

Could not load file or assembly 'EntityFramework' or one of its dependencies. The process cannot access the file because it is being used by another process

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' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'EntityFramework' could not be loaded.

=== Pre-bind state information ===

> LOG: DisplayName = EntityFramework  (Partial) WRN: Partial binding
> information was supplied for an assembly: WRN: Assembly Name:
> EntityFramework | Domain ID: 2 WRN: A partial bind occurs when only
> part of the assembly display name is provided. WRN: This might result
> in the binder loading an incorrect assembly. WRN: It is recommended to
> provide a fully specified textual identity for the assembly, WRN: that
> consists of the simple name, version, culture, and public key token.
> WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for
> more information and common solutions to this issue. LOG: Appbase =
> file:///C:/src/prjPptsWa/ LOG: Initial PrivatePath =
> C:\src\prjPptsWa\bin Calling assembly : (Unknown).
> === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\src\prjPptsWa\web.config LOG: Using
> host configuration file:
> C:\Users\Documents\IISExpress\config\aspnet.config LOG: Using machine
> configuration file from
> C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
> LOG: Policy not being applied to reference at this time (private,
> custom, partial, or location-based assembly bind). LOG: Attempting
> download of new URL
> file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary
> ASP.NET Files/root/17d130d2/d3bf1590/EntityFramework.DLL. LOG:
> Attempting download of new URL
> file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary
> ASP.NET
> Files/root/17d130d2/d3bf1590/EntityFramework/EntityFramework.DLL. LOG:
> Attempting download of new URL
> file:///C:/src/prjPptsWa/bin/EntityFramework.DLL. LOG: Using
> application configuration file: C:\src\prjPptsWa\web.config LOG: Using
> host configuration file:
> C:\Users\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 ERR: Failed to
> complete setup of assembly (hr = 0x80070020). Probing terminated.

Stack Trace:

[FileLoadException: Could not load file or assembly 'EntityFramework' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]

[FileLoadException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531

[HttpException (0x80004005): Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9946132
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261

Update:- Got a fix for my issue, the fix was to remove the mapping and remap to another folder. For some reason the old folder was holding dll's from being loaded.

c#
.net
asp.net-mvc
entity-framework
asked on Stack Overflow Jun 28, 2016 by Sandillio Sandy • edited Jun 29, 2016 by Sandillio Sandy

1 Answer

0

Your EntityFramework DLL is being used by another program in your system. This is the reason you can not load this assembly in bin, when you compile. I can not tell which program is currently using this dll. Do you have Panda AV installed in your machine. If yes disable it and try if it works.

answered on Stack Overflow Jun 28, 2016 by Saket Choubey

User contributions licensed under CC BY-SA 3.0