Visual Studio 2012 warning MSB3026: Could not copy DLL files
Asked Answered
C

13

45

I keep getting:

warning MSB3026: Could not copy dlls errors.

I have several projects in the solution.

On build, I also get the error:

Error 47 Could not copy "myapp\bin\Debug*.dll" to "bin*.dll". Exceeded retry count of 10. Failed.

The application just stops responding in the middle of debugging, and I have to close Visual Studio every time. Which was annoying, but now it's getting frustrating as well.

We are eight team members, and all of us are getting the same error. We can't rebuild the solution, and the application is running very slow.

One of things we are using in the project is SignalR.

These are the things I have tried so far. They didn't help me, but they might help the reader:

  1. I have tried solutions described in Visual Studio debugging/loading very slow, but that didn't work.

  2. I have also tried unchecking Enable the Visual Studio hosting process in each project properties and that didn't fix the issue either.

  3. Solutions are described in http://www.richard-banks.org/2008/04/how-to-fix-problems-with-locked-files.html and http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/40ed753e-47af-4638-8a72-1d607102a05c/

  4. Pre-build scripts on the projects: if exist "$(TargetPath).locked" del "$(TargetPath).locked" if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

  5. The bin folders are not under source control.

  6. Sometimes killing the Microsoft.VisualStudio.Web.Host.exe process releases the lock on the files, but this does not always work.

  7. I am running Visual Studio in administrator mode.

  8. I have full access (permissions read/write) on the source code folders.

Chance answered 28/3, 2013 at 18:20 Comment(15)
is this a build or deploy error?Charis
when i try to rebuild or clean the solution i get this error. the application is also running very slow. i always have to restart visual studio or kill the web.host.exe process before rebuilding the solution.Chance
by the way i have also tried solutions described here: richard-banks.org/2008/04/… and social.msdn.microsoft.com/Forums/en-US/msbuild/thread/…Chance
are you using any build definitions?Charis
are you using a shared library between multiple projects?Charis
yes i am using a couple of shared libraries (like data transfer objects and utilities projects).Chance
and no build definitions.Chance
have you tried cleaning and rebuilding your data layer?Charis
yes i have tried that. killing the process or closing/reopening the visual studio lets me do a clean but when i debug the app and then stop the debugging after that i cant clean the solution. and the rebuild also fails to delete the dlls.Chance
sounds like a locking issue. Still missing something, but not sure what...Charis
We are eight in the team and all of us are getting the same issue. Exactly the same issue. I have made sure that the bin folders are not under source control. I posted this question after nearly a month of trying everything I could find on the internet. Now its getting to a stage where it is really bothering me very much.Chance
I have also tried the following prebuild script on each project. if exist "$(TargetPath).locked" del "$(TargetPath).locked" if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"Chance
I have the same issue with a very simple project, few source files, and only "System" as a reference. No databases, no IIS, no funky stuff. Using Visual Studio 2010 on Windows 7 64-bit. If I launch my program and let it run until the end, then I can modify it and rebuild just fine. But if I break into it while it is running, and terminate it, then the next attempt to build will fail with MSB3026. It is driving me nuts. I am seriously considering launching a 32-bit Windows XP virtual machine to do my development in, because this situation is just unbearable.Wagers
Yep, this has been driving me nuts as well. Did VStudio 2013 become worse on this problem? I've wondered if being able to alter the code while running setting makes this problem worse?Bhang
I have installed vs 2013 but because of tight deadlines I haven't been able to try my hands on it. Would be great if the issue is fixed in vs 2013. I never alter the code while debugging. I have the option turned off anyway.Chance
E
13

This is generally a permissions issue with your bin directory. Navigate to it in Windows Explorer and make sure readonly is off. If you get an error changing the read status of the directory, make sure you're running on an administrator-level account or elevate accordingly. Once write permissions are re-enabled, your build should work fine.

Eelpout answered 28/3, 2013 at 19:2 Comment(7)
thanks for the reply. that was the first thing i checked. the bin folder is readonly. if i uncheck and save it and open the properties again it goes back to readonly. there must be something that is setting it to readonly.Chance
If removing readonly isn't sticking, you may not have sufficient privileges to change it, or IIS Express may have gone off the rails. Again, make sure you are an administrator. You might want to open Windows Explorer temporarily as an admin (right-click, run as administrator) as well to get around any UAC weirdness. If that's not working, close Visual Studio completely and make sure that the devenv.exe process has been terminated. Then try changing it again and reopen Visual Studio afterwards.Eelpout
Thanks Chris. I tried it this morning but the read-only attribute comes back as soon as I click OK on the properties popup. Visual Studio is closed. IIS Express is not running. The site is not using regular IIS. Microsoft.VisualStudio.Web.Host.exe is also not running. It must be something else then. I also killed all the TFS processes and still no luck. However, saying that, bin folder is read only but I can now delete all the files in the bin folder.Chance
Well, deleting everything in the bin folder should be as good as anything else. If the file isn't there, Visual Studio should have no problems writing it. Are you still having issues?Eelpout
The thing is that closing visual studio every half an hour and deleting the files manually and reloading is not working very well for me. For example, right now, the application just stopped responding and I know if I close visual studio and delete the files in the bin folder then everything will be fine until the application wont build or will stop responding during the debug again.Chance
The bin folder is not read-only. The read-only checkbox is simply grayed, meaning that Windows does not know, or cannot be bothered to actually find out, whether the folder is in fact read-only. And actually it is not. The grayed read-only checkbox can be found in all folders in all windows installations, and it is just one of those ways that windows is broken and we have to live with it. It has nothing to do with the problem at hand.Wagers
It was indeed a permissions issue. Thanks for the answer.Parentage
S
9

Clean Solution, then Rebuild Solution fixed this issue for me.
The first time I tried to perform a Clean, I got an access violation error.
To remedy that, I exited VS, manually deleted the bin folder, and opened it back up. Then I could perform the Clean.

This had nothing to do with permissions or access level.
Ensuring the output directory was not read-only and running VS as Admin did not help.

Please refer to Visual Studio “Could not copy” … during build.

Stolid answered 17/9, 2014 at 14:25 Comment(1)
Worked like a charmBasswood
C
5

Open cmd (command prompt) as admin. View tasklist with

tasklist

Note the pid of the project .exe file. Run taskkill to kill the process:

taskkill /F /IM YOUR_PID

Restart the Visual Studio, clean and rebuild project. That should get the job done.

Contingency answered 31/7, 2022 at 22:18 Comment(0)
Q
3

I ran into this issue as well, seems like a known bug in VS that randomly gets people from time to time in 2010, 2012 and 2013, I tried many of the suggestions here, as well as few found on other sites, none worked. What helped me was going into the debug properties for the project and clearing "Enable Visual Studio Hosting process", rebuild all and no more error.

Hopefully this will work for you, but that said, as it is a known reported bug in VS itself, we might all be fixing the symptoms and luckily doing something to clear the file lock and the real problem remains in VS.

Quintillion answered 18/4, 2014 at 19:38 Comment(2)
So you have checked this when debug (because its supposed to somehow improve debug experience) and unchecked when deploy ?Woermer
this option is not in VS2017 anymoreWoermer
Z
3

Same issue for me. Solution was that I had my debugger still running the program in the background.

Zoe answered 4/5, 2017 at 3:33 Comment(0)
E
2

I had this issue several days ago and tried many approaches but the solution that worked for me was stopping a windows service that was used by some class libraries from the project.

Ethanol answered 27/10, 2015 at 9:7 Comment(0)
H
2

This worked for me:

  1. Close VS
  2. Delete bin and obj folders.
  3. If the project is located in any cloud-service-synced folder like OneDrive, move it to a local, regular folder.
  4. Delete .suo file inside solution folder
  5. Open VS again and rebuild.

Some similar issues deal with the dlls being locked so they cannot be copied, in which case, help can be found here and here!

Harborage answered 26/3, 2020 at 14:41 Comment(0)
E
1

I had the same issue. It seems that the dlls visual studio trying to copy is corrupt or something like that. I tried to copy the particular dlls to my desktop but it failed with error message. So I replaced the entire dlls with the fresh ones, which solved my problem. Hope that helps.

Eisenhower answered 28/10, 2013 at 8:24 Comment(0)
M
0

This issue had been plaguing my development for sometime. Regardless of disabling the Read Only security permission and modifying access rights of the affect dlls.

I resolved the issue by ensuring the Security Permissions on the parent folder of solution allowed the computer's administrator read and write access and then ran Visual Studio in Administrator mode.

Misprint answered 27/9, 2013 at 9:25 Comment(1)
Thanks @jRobbins. I have full access to the source code folders and I am running visual studio in administrator mode.Chance
I
0

I had two projects

  • Source/Repos/Project1
  • Source/Repos/Project2

Project 1 had added Project 2 as an existing project (Two non-adjacent folders) The error message happened.

But when I moved Project2 (as a folder) into Project 1, then the error message left.

New Structure was:

  • Source/Repos/Project1
  • Source/Repos/Project1/Project2

Once I add The Project2 as an 'existing project' into Project 1 everything worked.

Intoxicating answered 12/11, 2021 at 23:47 Comment(0)
D
0

Check your project's folder path length.

Dropline answered 19/5, 2022 at 8:9 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Deterrent
L
0

I had a unit test that remained hung after the test had "ended" in VS2022. I even closed VS2022 and the testhost.exe remained running.

The big clue is the first error of this type will include testhost.exe' is denied. and testhost.dll' is denied. because those are the programs generated for running a unit test.

I had to use End task in Task Manager in order to stop the hung test host. Then I was able to clean and rebuild.

Latour answered 23/6, 2022 at 23:27 Comment(0)
H
-1

I had the same issue.Clear the browser history and build the project. which solved my problem. Hope that helps.

Hemocyte answered 15/5, 2014 at 8:37 Comment(1)
What could be the link between the browser history and the build process of VS?Timehonored

© 2022 - 2024 — McMap. All rights reserved.