user3158518
user3158518

Reputation: 93

I have a error when i try to compile my wpf app written in c# code

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

Upvotes: 2

Views: 301

Answers (4)

Avneesh Srivastava
Avneesh Srivastava

Reputation: 437

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

Upvotes: 0

mrzli
mrzli

Reputation: 17359

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.

Upvotes: 1

Patrick Hofman
Patrick Hofman

Reputation: 156918

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

Upvotes: 1

SOReader
SOReader

Reputation: 6007

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.

Upvotes: 3

Related Questions