.

Unable to copy from obj\debug to bin\debug [solution/resolved]

Error 1 Unable to copy file “obj\x86\Debug\<>.exe” to “bin\x86\Debug\<>.exe”. The process cannot access the file ‘bin\x86\Debug\<>.exe’ because it is being used by another process. <>

This is due to a bug in Visual Studio (as it turns out that the file is locked by devenv.exe)

Here is the fix:

We need a pre-build action to remove the locked file.
Go to your project’s properties (in the solution explorer, right-click project and select the Properties option), click Build Events tab. Add this following script:

if exist “$(TargetPath).locked” del “$(TargetPath).locked”
if exist “$(TargetPath)” if not exist “$(TargetPath).locked” move “$(TargetPath)” “$(TargetPath).locked”

One Response to this post.

  1. Posted by pietman on 06.07.12 at 12:41 pm

    otherwise … try this:

    if exist “$(TargetPath).locked” del “$(TargetPath).locked”
    if exist “$(TargetPath)” if not exist “$(TargetPath).locked” move “$(TargetPath)” “$(TargetPath).locked”

What's your thoughts on this?

*

Protected by WP Anti Spam