Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit: "The process cannot access the file ... because it is being used by another process."

Tags:

nunit

I'm using the NUnit GUI version, and it started to get upset at me when I have a test project loaded in there trying to test things. If I make a change in Visual Studio, and then try to rebuild the solution, it throws the error "Unable to copy file obj\Debug\foo.dll to bin\Debug\foo.dll. The process cannot access the file bin\Debug\foo.dll because it is being used by another process."

This is the DLL I have loaded into the GUI, of course. It used to be OK, and just refresh the project reference after a build, but now it seems to be blocking it. How can I get back to that behavior?

I've tried enabling/disabling the shadow copy setting by the way, with the same results either way.

VS2008 SP1 and NUnit 2.4.8, if that matters.

like image 523
Chris Avatar asked Jun 01 '09 15:06

Chris


3 Answers

Figured it out: the "Volume Shadow Copy" service was shut off for some reason. Turned it back on, and everything's back to normal.

like image 157
Chris Avatar answered Sep 24 '22 10:09

Chris


I just wanted to add that moving the Nunit project file to the solution location solved my issue. I did not have to change any shadow copying setting in nunit or to enable shadow copying service.

See Stack Overflow - nunit locking dll

like image 35
Valamas Avatar answered Sep 22 '22 10:09

Valamas


I had the same problem as mentioned in the Question. I solved it on my machine by the following:

  1. Within Visual Studio > Solution Explorer > select the dll that is causing the problem > right click > select properties. After this action the File properties of the dll should now be visible.
  2. Within the file properties view of the dll; set the Copy To Output Directory to Copy if newer.

If you have the Copy to Output Directory as Copy always you will get the compile error mentioned in the question. If you make the change mentioned above it should go away and your dll will still be copied.

like image 20
ryan Avatar answered Sep 22 '22 10:09

ryan