locked
Unable to copy file "obj\x86\Debug\MyProgram.exe" to "bin\Debug\MyProgram.exe" RRS feed

  • Question

  • Okay, I have looked at other solutions and none of them worked. My problem is a little different. Whenever I create a new project and type some code, and compile it either debug or non-debug mode, it works fine. Now if I type some more code or change the current code, and try to run the program again, this error shows up.

    Unable to copy file "obj\x86\Debug\Sample.exe" to "bin\Debug\Sample.exe". The process cannot access the file 'bin\Debug\Sample.exe' because it is being used by another process.

    Even if I restart VS, this error shows up. I am forced to log out and log in again to get rid of this error. But if I change the code again, this error will show up.

    I tried doing a complete uinstall of VS and .NET 4.0 but still no luck. This also happens on Visual C# Express. I tried using the Task Manager but the program or process does not show there. Please help me. My last solution is to reformat my computer and do a clean installation but I really don't want that to happen. Please help.

    After waiting for around 10mins, and recompiling, it works fine again. But again, if I change the code and recompile, this error occurs.

    Wednesday, July 27, 2011 12:11 PM

Answers

  • As the error describes it self that Visual Studio is unable to copy you EXE from the compiled location to the output location, Basically it is because your application is still running or is being used by another process ( some times Antivirus does this ).

    When this error occur again go to task-manager "CTRL+ALT+DEL" and in the process tab check if your application is running ( Name.exe or name.vshost )

    if it is running then close it and start your appliation and check

    Project -> settings -> Application -> Shutdown Mode -> ?

     


    Faraz
    • Marked as answer by Alexander Sun Friday, December 9, 2011 8:39 AM
    Thursday, July 28, 2011 9:54 AM
  • thank you so much for your response. you just saved me. big time. the problem was that the program was running somewhere in the background where I couldn't see. task manager solved it
    • Marked as answer by Alexander Sun Friday, December 9, 2011 8:39 AM
    Wednesday, December 7, 2011 10:03 AM

All replies

  • As the error describes it self that Visual Studio is unable to copy you EXE from the compiled location to the output location, Basically it is because your application is still running or is being used by another process ( some times Antivirus does this ).

    When this error occur again go to task-manager "CTRL+ALT+DEL" and in the process tab check if your application is running ( Name.exe or name.vshost )

    if it is running then close it and start your appliation and check

    Project -> settings -> Application -> Shutdown Mode -> ?

     


    Faraz
    • Marked as answer by Alexander Sun Friday, December 9, 2011 8:39 AM
    Thursday, July 28, 2011 9:54 AM
  • thank you so much for your response. you just saved me. big time. the problem was that the program was running somewhere in the background where I couldn't see. task manager solved it
    • Marked as answer by Alexander Sun Friday, December 9, 2011 8:39 AM
    Wednesday, December 7, 2011 10:03 AM
  • Hi

    I seem to be having the same problem however when I try to end process in task manager it restarts again by itself. The only way I can seem to get around it is to qut Visual C# and relaunch then I am able to compile without that error.

    • Proposed as answer by Alexander Sun Tuesday, March 13, 2012 5:52 AM
    Saturday, March 10, 2012 5:00 PM
  • I had the same problem. Every time I change the code and recompile that error comes up. I couldn't delete the MyProgram.exe file in the bin/Debug folder, so I made another folder somewhere else in my computer called "ToBeDeleted" then I just moved (Cut and Paste) the MyProgram.exe file in to the ToBeDeleted folder. 

    This method works, however it was making my computer slower and slower. Once I had about 15 of these files, MyProgram2.exe, MyProgram3.exe etc, My computer was really slow so I shut down visual studio and checked Task Manager. MyProgram.exe was not in Task Manager, but there were heaps of visualNUnit.exe processes running. At this stage I couldn't delete these 15 files in my tobedeleted folder, but after I ended a visualNUnit process I could delete one of them at a time, (before it starts back up again). I was able to delete all of the 15 files in the tobedeleted folder, and my computer is now running faster. Next time I start up visual studio I will disable Visual NUnit and see if that solves the problem.

    Another thing I noticed is that a few times my program threw an exception and crashed. After this crash, I was able to fix the problem and recompile, without getting that error message(Unable to copy file blah blah blah because it is being used by another process.) So i was thinking I could put a button in my program that purposely makes it crash so I won't have that problem anymore. 

    The reason why it crashed is because I called the PrintDialog.Show() (or something like that) but I didn't create the PrintDialog object so it was null. It was a null excetpion or something.

    So I've given you a few ideas, I hope this helps some people.


    Wednesday, May 30, 2012 11:02 AM