Share via


Unable to copy file reference.dll to bin/reference.dll. The process cannot access the file reference.dll because it is being used by another process

Question

Thursday, July 9, 2009 2:22 PM

 Hey all,

For one of my ASP.NET 3.5 applications, every single time I try to build the web app, it throws the following build errors:

Error 165 Unable to copy file "C:\InOne\Common\DexProcessor\bin\Debug\DexProcessor.dll" to "bin\DexProcessor.dll". The process cannot access the file 'bin\DexProcessor.dll' because it is being used by another process. InVision2
Error 166 Unable to copy file "C:\InOne\Common\DexParser\bin\Debug\InOne.DexParser.dll" to "bin\InOne.DexParser.dll". The process cannot access the file 'bin\InOne.DexParser.dll' because it is being used by another process. InVision2
Error 167 Unable to copy file "C:\InOne\Common\AlertProcessor\bin\Debug\InOne.Invision.AlertProcessing.dll" to "bin\InOne.Invision.AlertProcessing.dll". The process cannot access the file 'bin\InOne.Invision.AlertProcessing.dll' because it is being used by another process. InVision2
Error 168 Unable to copy file "C:\InOne\Common\InVision.BusinessLogic\bin\Debug\InVision.BusinessLogic.dll" to "bin\InVision.BusinessLogic.dll". The process cannot access the file 'bin\InVision.BusinessLogic.dll' because it is being used by another process. InVision2
Error 169 Unable to copy file "C:\InOne\Common\InVision.Common\bin\Debug\InVision.Common.dll" to "bin\InVision.Common.dll". The process cannot access the file 'bin\InVision.Common.dll' because it is being used by another process. InVision2
Error 170 Unable to copy file "C:\InOne\Data\bin\Debug\InVision.Data.dll" to "bin\InVision.Data.dll". The process cannot access the file 'bin\InVision.Data.dll' because it is being used by another process. InVision2
Error 171 Unable to copy file "C:\InOne\Common\InVision.DataAccessLayer\bin\Debug\InVision.DataAccessLayer.dll" to "bin\InVision.DataAccessLayer.dll". The process cannot access the file 'bin\InVision.DataAccessLayer.dll' because it is being used by another process. InVision2
Error 172 Unable to copy file "C:\InOne\Common\InVision.DataAccessLayer.SqlClient\bin\Debug\InVision.DataAccessLayer.SqlClient.dll" to "bin\InVision.DataAccessLayer.SqlClient.dll". The process cannot access the file 'bin\InVision.DataAccessLayer.SqlClient.dll' because it is being used by another process. InVision2

I read online to add some pre-build events but that didn't work for me. I also tried adding to the project files:

<GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

This just started happening a couple days ago and is very annoying... I have to go into the web app's bin folder and delete the pdb files and then it'll let me delete the dll's most of the time. Every once in a while it doesn't let me so I have to close Visual Studio and then it lets me delete them.

This is really reducing my productivity, is there anything I can do to resolve this?

Thanks,

Justin

All replies (5)

Thursday, July 9, 2009 3:04 PM ✅Answered

 Ok I assume since this has been a few days I would have assumed you have tried to re-boot, but some people develop for days on end without re-starting; have you done this (just as a check mark). 

I have had this happen to me at least a half dozen times since developing in VS.NET 2008.  Sometimes, I believe that one of the WebDev.WebServer.exe processes (icon that is down in the tray when debugging a project; can be shut down in TaskManager) gets hung up and locks those files.

For me 1 of (3) things has fixed this issue.

  1. Restarting Visual Studio
  2. Shutting down all instances of WebDev.WebServer.exe either manually or via TaskManager in Windows.
  3. Re-booting the machine.

One last effort may be to clear any temporary cached files that VS.NET is using.  Here is an article on clearing them:

http://robertbogley.wordpress.com/2007/09/19/how-to-speed-up-loading-time-in-microsoft-visual-studionet-2005-projects/

...by the way the folder location for Step # 2 from the above link if using Vista is as follows:

C:\Users\UserName]\AppData\Local\Microsoft\WebsiteCache

Hope this helps!


Thursday, June 3, 2010 11:28 AM ✅Answered

Check your web.config for:

<hostingEnvironment shadowCopyBinAssemblies="false" />

If it's there then remove it and it should fix the issue.


Thursday, July 9, 2009 4:38 PM

Thanks for the quick reply.

I use IIS rather than the web dev server so that one isn't an issue. I've tried rebooting multiple times and resetting iis to no avail. I read the post and cleared all of those temp directories, then rebooted, and the first rebuild it still gives the errors...

Any other things I can try??


Saturday, July 11, 2009 4:06 PM

:: bump :: 


Thursday, June 3, 2010 10:48 AM

Till Date, I find no solution to the problem below.

Unable to copy file "obj\Debug\Tax2010.dll" to "bin\Tax2010.dll". The process cannot access the file 'bin\Tax2010.dll'

because it is being used by another process. 

In my case, I have two projects under one Solution named "Tax2010"

1) Calc and Calc.DLL (contains .cs class files)

2) Tax2010 and Tax2010.DLL (contain .aspx pages along with respective .cs files and other .cs class files)

I have configured both the projects in a way that their respective .dll be copied to one common bin directory placed under
Tax2010 directory.

Here is the genral hierarchy of the project.....

Tax2010
   Tax2010
 Bin
   Tax2010.DLL
   Calc.DLL
 UI
   ....aspx
   ....cs
 CL
   ....cs
   ....cs 
   Calc 
        AK
   ....cs
   ....cs

The problem happens whenever I make any changes to .cs file and try to build the project.One interesting thing to note,

though, is that I am not running the application through IIS. Its using WebDev.WebServer.Exe. How I am dealing with it right

now ?

  1. Delete the obj folder and build the peoject. It works fine
    or
  2. CTRL + ALT + DEL - > Task Manager -> Processes -> WebDev.WebServer.Exe - > End Process.

Now I am sick and tired of doing this monotonous job. Please somebody come up with some wow solution. Enough is Enough now.