Visual Studio Build Fails: Unable to Copy Exe-File from Obj\Debug to Bin\Debug

Unable to copy a file from obj\Debug to bin\Debug

@Udpate: Since the time I was first posting this 'answer', I tend to another explanation to the problem. The issue since than happened more and more often outside of Visual Studio also - while trying to copy an .exe file from one folder to another. While in the first place Windows did not allow to copy(!) an .exe file (it was first asking me for administrative rights but refused to copy it afterwards anyway) it still showed up in the explorer. But after a while - without any further action taken, it disappeared magically. Just like the problem in the question always seems to solve itself after a while. So i assume, the problem is more related to a delayed deletion of the project output file and less a buggy VS. I apologize for any unjustified suspicion. :|

This gives the search for a solution a complete different direction, I guess. Did find that link and will update on any progress:

https://superuser.com/questions/234569/windows-7-delayed-file-delete

========================================================================

This is a known bug in VS. I discovered it very often - mostly in VS2010 (with/without SP1). Several "solutions" are recommended. Some of them, which kind of helped for me:

  1. Delete the .suo file in your project dir. Eventually need to create your whole solution from scratch.
  2. Close any Windows Form Designers may remain open.
  3. Use a prebuild script, which deletes the target from the output dir.
  4. Disable the VS hosting process.

None of these really fixes the bug. But it may brings the VS back to a usable state - until a true solution is provided by MS (if ever will).

http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/cea5e4b2-5b33-453c-bffb-8da9f1a1fa4a

http://social.msdn.microsoft.com/Forums/en/vbide/thread/cd12f3c7-de96-4353-adce-23975e30933f

Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug

This is going to sound stupid, but I tried all these solutions, running VS2010 on Windows 7. None of them worked except the renaming and building, which was VERY tedious to say the least. Eventually, I tracked down the culprit, and I find it hard to believe. But I was using the following code in AssemblyInfo.cs...

[assembly: AssemblyVersion("2.0.*")]

This is pretty common, but for some reason, changing the version to 2.0.0.0 made things work again. I don't know if it's a Windows 7 specific thing (I've only been using it for 3-4 weeks), or if it's random, or what, but it fixed it for me. I'm guessing that VS was keeping a handle on each file it generated, so it would know how to increment things? I'm really not sure and have never seen this happen before. But if someone else out there is also pulling their hair out, give it a try.

Visual Studio Could not copy .... during build

I have encountered similar error messages in Visual Studio 2013.

Mostly, I have found that this situation has occurred when a debug process was halted because of an exception.

When clean+build has not resolved this problem for me, I have had success by doing the following:

  • Closing Visual Studio
  • Deleting the bin and obj folders, and
  • Reopening Visual Studio.

This "bug" has existed since Visual Studio 2003.

Finally, I have also found that I can often overcome this problem by simply renaming the executable file and then deleting it.

Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug

This is going to sound stupid, but I tried all these solutions, running VS2010 on Windows 7. None of them worked except the renaming and building, which was VERY tedious to say the least. Eventually, I tracked down the culprit, and I find it hard to believe. But I was using the following code in AssemblyInfo.cs...

[assembly: AssemblyVersion("2.0.*")]

This is pretty common, but for some reason, changing the version to 2.0.0.0 made things work again. I don't know if it's a Windows 7 specific thing (I've only been using it for 3-4 weeks), or if it's random, or what, but it fixed it for me. I'm guessing that VS was keeping a handle on each file it generated, so it would know how to increment things? I'm really not sure and have never seen this happen before. But if someone else out there is also pulling their hair out, give it a try.

Error 1 Unable to copy file obj\Debug\SourceProject.exe to bin\Debug

Just open your Debug Configuration near by Application Run Button in VS. Then , Choose debug with Any CPU to x64 or x86 .. May be it will help someone.

Thanks,



Related Topics



Leave a reply



Submit