views:

60

answers:

3

Using Visual Studio 2010, when I build + run my application in short intervals I often get the following error. If I just wait a minute or two and try again it works fine. Unlocker claims no handle is locking the executable file.
How can I discover what's locking it?
If it's Visual Studio itself, what should I do to make it stop? or alternatively to release the file?

1>------ Build started: Project: MyProj, Configuration: Release Win32 ------
...
1>InitializeBuildStatus:
1>  Creating "Release\MyProj.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1>  All outputs are up-to-date.
1>  SomeFile1.cpp
1>ResourceCompile:
1>  All outputs are up-to-date.
1>LINK : fatal error LNK1104: cannot open file 'D:\...\MyProj.exe'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.94
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
A: 

http://msdn.microsoft.com/en-us/library/ts7eyw4s(VS.71).aspx

Can be caused by various things.

kyndigs
From the various options in the link, the applicable ones are: 1) Insufficient file permissions 2) Another program may have the file open and the linker cannot write to it. This still does not help me debug the issue
Jonathan
A: 

the file can be locked because it is being run now. Try killing the process with a task manager.

portland
It is not run, I checked in task manager.
Jonathan
A: 

You probably had a stray build process that was locking the executable, and it (the stray process) didn't get cleaned up. In that case, shut down visual studio, open up process explorer, and nuke every process you can find that is related to visual studio. Then open up visual studio again and try rebuilding your project.

C Johnson
This is such a common problem for me that the process you detail is too tedious to do each time. Any other ideas?
Jonathan