2

I keep getting this error message when I try to compile my app:

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

Ankush Madankar
  • 3,689
  • 4
  • 40
  • 74

4 Answers4

3

You still have your application running. Check if there are no processes hanging in taskmgr. If not, close MSVS, delete bin and obj folders, reopen MSVS and try again.

SOReader
  • 5,697
  • 5
  • 31
  • 53
1

Try to close Visual Studio and try again. Maybe you need to close the vshost program using Task Manager.

Sometimes the files get locked, but usually they are freed by closing and reopening Visual Studio.

Also see this question on SO

Community
  • 1
  • 1
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
1

Like it states, some process is using that file. Restarting Visual Studio might not be enough.

This happens to me sometimes because Avast Antivirus tries to scan and do whatever else it does to the exe of my application, and for some reason does not release it later.

One option would be to restart the computer.

Another would be to use something like Process Explorer and use it to release the handle on that file.

Using Process Explorer, you can release the file using this steps:

  1. Find->File Handle or DLL...
  2. In the dialog that opens search for the file and select it
  3. Close the dialog and in the main window on the selected process right click and Kill Process.
mrzli
  • 16,799
  • 4
  • 38
  • 45
0

Try this its work for me just clean your solution and then Build Solution.