4

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?

11
  • 1
    What do you mean by occupies? Is there some specific error message you get? Commented 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. Commented 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. Commented 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. Commented 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! Commented Apr 26, 2011 at 13:35

3 Answers 3

3
+50

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

Sign up to request clarification or add additional context in comments.

5 Comments

@Teoman Soygul. I read your solution and it is like you said it doesn't solve the root of the problem. I have in mind to appeal to microsoft thou a serious channel, which i don't know what will be.
Here you can fill in a bug report, they take it seriously: connect.microsoft.com/VisualStudio
@Teoman Soygul. I found that your approach to the issue is the most close to what I'm looking for. And just for this I decide to give you the 50points of reputation credit. Thank you very much for your concern.
You're welcome. This works form me most of the time for this sort of lockups.
@Teoman Soygul. I vote your answer because you know it from the first time that the answer is a solution which will not come from our own moves, thats why you said "It's not solving the root of the problem" but needs to face it as a bug from MS. And secondly you proposed me a serious place to post it as a bug
0

It may also not be Visual Studio locking your executable, check the locks on it with "Unlocker": http://www.emptyloop.com/unlocker/

1 Comment

I did that and the lock is coming from the VS itself. The lock is coming suddenly and goes itself, just like that.
0

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

1 Comment

Klaus. Yes I do that as well, but this is not the solution in the problem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.