0
Could not load file or assembly 'Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

Hi, i get this error when trying to "enable-migrations" on my infrastructure project which contains the EntityFramework reference.

This is a fresh project, that i created to debug my ASP.NET MVC project, which gives me the same error.

This is the project structure of my basic (new) console application:

Structure

I have tried re-installing SQL server and clean/rebuild solution.

Im running on VS2015.

PS: Dont mind the logic.cs file as its just a dummy function to see if it had anything to do with project referencing. (And it didnt)

Full error:

PM> enable-migrations
No packages installed.
The EntityFramework package is not installed on project 'dbfirsttest'.
PM> enable-migrations
System.IO.FileLoadException: Could not load file or assembly 'Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
File name: 'Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.IO.FileLoadException: Could not load file or assembly 'Infrastructure' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
File name: 'Infrastructure'


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.LoadAssembly(String name)
   at System.Data.Entity.Migrations.Design.ToolingFacade.GetContextTypeRunner.Run()
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.GetContextType(String contextTypeName)
   at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName)
   at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)


Could not load file or assembly 'Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
PM> 

Any help or tips on this issue is greatly appreciated

Christer
  • 1,651
  • 1
  • 17
  • 34
  • Either dbfirsttest or domain is trying to load the assembly from the infrastructure project. Check your build dependencies. – Thane Plummer Sep 28 '15 at 00:17
  • Hi Thane, Thanks for a quick response, im not sure what you meen actually. (these are test projects for me to learn the technology) - I have checked Build dependencies. ( http://imgur.com/ceTzFre ) And it looks correct. Altough, in the diagram, it doesnt say that dbfirsttest also depends on domain, but when checking dependencies on the project, it shows correctly. Please tell me if i checked it the wrong way :) – Christer Sep 28 '15 at 00:24
  • Can you post the content of packages.config and "References"? (in Infrastructure) – Oberheim Sep 28 '15 at 08:38
  • @Christer Check the project "References" in the dbfirsttest and domain projects. If either project has a Reference to `Infrastructure` with a red X next to it, it means it's trying to load that reference but it failed. Let me know if this is the case and I'll show you how to solve it. If this is not the case, then my assumption about the cause is incorrect. – Thane Plummer Sep 28 '15 at 13:44
  • Hi, sorry i havent gotten back to this, i will try to check this again tonight. – Christer Sep 30 '15 at 09:13
  • @ThanePlummer, No references has a red X. – Christer Sep 30 '15 at 22:02
  • @Oberheim, http://imgur.com/r81j8Cj – Christer Sep 30 '15 at 22:05

0 Answers0