From Time to time my visual studio 2010 occupies the executable program in Debug subdirectory.
Thus I have to unload the solution and reload it. Then ReBuild it and then run it.
The all situatuation becomes upseen
I really can't work like that. I have already unclick in Debug section the
Enable the Virtual Studio hosting process
Is there any one to help me on this situation?
- 1What do you mean by occupies? Is there some specific error message you get?mjcopple– mjcopple2011-03-28 21:45:09 +00:00Commented Mar 28, 2011 at 21:45
- @mjcopple. When I say "occupies" I mean it holds it and I can't deleted. This phenomenon it's not happens every time. Suddenly comes up and suddenly disappears.Lefteris Gkinis– Lefteris Gkinis2011-04-11 06:35:51 +00:00Commented Apr 11, 2011 at 6:35
- Are you running your built app with CTRL-F5? This spawns an independent process that will cause consequent builds to fail since the executable is held and cannot be overwritten.lysergic-acid– lysergic-acid2011-04-23 08:44:23 +00:00Commented Apr 23, 2011 at 8:44
- I suggest you check out external packages or VS addins that could run in your VS instance and see if it continues to work. You could also ensure your antivirus is not messing with your build directories, some of these programs are picky about this.Simon Mourier– Simon Mourier2011-04-24 07:04:04 +00:00Commented Apr 24, 2011 at 7:04
- I always use CTRL+SHIFT+B to build my programs in between development cycles. If you could explain what you're doing to build or to debug your solution we could give you better help. Also, remember that if you're running in debug mode you can't change parts of your code that are meant to be compiled! That includes the outcome, that is your executable!bastianwegge– bastianwegge2011-04-26 13:35:34 +00:00Commented Apr 26, 2011 at 13:35
3 Answers
Well this is a bit of a workaround but works for me most of the time. This doesn't solve the root cause but the symptoms (the file locking):
Add this as a pre-build event:
if exist "$(TargetPath).locked" del "$(TargetPath).locked" if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked" (Source of the solution: http://nayyeri.net/file-lock-issue-in-visual-studio-when-building-a-project)
Also here there is a similar problem and a liberal solution: Visual Studio 2010 build file lock issues
5 Comments
It may also not be Visual Studio locking your executable, check the locks on it with "Unlocker": http://www.emptyloop.com/unlocker/
1 Comment
When this happens I open Process Explorer and use the Find - Find Handle or Dll menu to find the process which has the file still open. From there I can jump the the handle in the process and close it from within Process Explorer. That works although it is a bit hacky.
Yours, Alois Kraus