Visual studio process Unable to copy file - visual-studio-2010

i have a visual studio 2010 , when i run project normal runs, and when i close window then make some changes and run, they says
"Error 5 Unable to copy file "obj\x86\Debug\Passport.exe" to "bin\Debug\Passport.exe". The process cannot access the file 'bin\Debug\Passport.exe' because it is being used by another process. Passport"
as i see in Passport.exe still in task manager. why?
(when i end that process again i can build project)
NOTE for my other projects no that problem, only for this.
Many thanks who can help :)

There are many reasons why this could happen, but basically it boils down to your passport process or a child process of it, not closing as soon as you "close the window".
Things to check:
1. Extra threads not being terminated (worker threads not complete etc.)
2. Debug, breakpoints causing closure process to hang.
First I would remove all breakpoints and then look at what processes you may be running that could be holding up process closure e.g. worker threads, file writing, hardware access.
Sometimes it's best to kill processes using the stop button in Visual Studio.

Related

Visual Studio - Terminate program execution?

If I run a program using Start Without Debugging, I want to be able to terminate that process. I am looking for a key combination or option in the menu to be able to do this. How can this be done?
I am not talking about terminating the program while debugging.
I believe that there is no 'yes' answer for this question. When you start without debugging it just launches a new, separate process and as such, it couldn't be terminated from within a Visual Studio.
The only different scenario I could find here, is when you are working on a web project, for which VS is launching a hosting process (a HTTP server, like IIS Express). If you kill your VS then, it will kill the process hosting a web application, so it is a kind of dependent process.
But still there's no shortcut for that. So that means there's no such way from VS.

How to know which devenv process to kill when multiple VS are open

I have 3 Visual Studio 2012 open at the same time. One just got stuck and i need to kill it but in the Task manager i see 3 apparently identical devenv processes. I can't understand from memory usage which one to kill. Is there a way to know which solution is used by each process so that i can kill the stuck?
Probably procMon is the answer but i'd like to avoid to open it if there's a faster way from TaskManager
Thank You
If you have opened different projects, use free tools like ProcessExplorer (http://technet.microsoft.com/en-in/sysinternals/bb896653.aspx) and check the project that has been opened and terminate it.

Killing child processes when debugging ends

I have a C++ project in Visual Studio 2008 that, when executed, spawns another process (due to a GUI library that is being used). However when I exit the main process (either using Ctrl-C or by stopping the debugger), the spawned process (and hence the GUI) remains. This is a side-effect of the library being used, and the nature of the project - it is designed to be embedded, and hence never really "exit", but debugging and testing is Windows-based. The orphan process then stops me being able to run the software again, without first killing it.
Using Process Explorer I can see that the spawned process is a child of the process being debugged. I would like a way to, when I end debugging of a project, kill all child processes.
The Chromium project has a macro which will grab child processes in order to attach to them. This is designed to be associated with a button in the VS GUI, and seems to be chrome-specific (that is, you would need a different button for a different project/parent-process).
I have looked into using the DebuggerProcessEvents::OnProcessStateChanged macro, the idea being that when the debugger stops I could walk through the child processes using a similar idea to the Chromium macro and <evil voice>kill them</evil voice>... but this event never seems to be triggered.
Any thoughts? The project is Makefile-based, due to the code being generated outside of Visual Studio, so I will be limited in the options I can set project-wise.

What's the advantage for 'attach to process' compared with 'Start Debugging'?

I am new to programming.
I know only Start debug before. Maybe start debug suit for some small application develop better.
I found Visual studio IDE provide another method of attach to process for using.
When & Why must I use the attach debugging?
Such as multi-threading application debugging. Client/Service application debugging. etc. Thank you.
Sometimes you need to debug a process started by another program.
For example you need a reliable solution and in order to protect against access violations, memory leaks and other barely recoverable stuff, you have a master program and several worker programs. The master program starts the worker program and passes parameters to it. How do you debug a worker program which is not intended to be started by anything except the master program?
You use "attach to process for that".
Typically you do it this way: insert a statement that blocks the worker program for some time - for example, call Sleep() for 15 seconds. Then you kindly ask the master program to start the worker program. When the worker program is started it blocks and you now have 15 seconds to attach to it.
This way you can debug almost any issues - problems at early startup stages, wrong parameters, etc, which you wouldn't reliably reproduce with "run with debugging".
Attaching to a process is useful if you don't want to debug right from starting the process. For example, debugging usually slows down execution, so it can be quicker to start the app, get it to a state where a bug appears, and then attach a debugger.
It's also useful if you already have an external means of launching the process that you don't want or can't to import into the IDE.
Start debugging from VS launches an instance of the VS webserver and attaches the debugger to it.
Attach to process allows you to attach to any process and debug it, usually you'd do this to your instance of w3wp.exe running your code in IIS
Attach to process is mostly used when you can't run the application from Visual Studio.
For example, if it's a service or if it is a process that has run for a long time and now you want to start debugging it.
Sometimes you also want to debug a remote process, not on your machine - and you can do that using attach to process.

Automatically attach vs2005 debugger to a child processes

I have a main C++ app built in Visual Studio 2005, called A.exe. It spawns a child process, B.exe. I run process A in the debugger by hitting F5 -- the only way I know to hit breakpoints in process B is to wait for A to kick it off, then run Debug -> Attach to Process, and manually select B.exe. This doesn't work very well if I need to debug initialization code in process B -- I have to start putting in 10 second sleeps at the beginning.
Is there some trick in the vs2005 GUI that I'm missing?
I'm using native code, by the way.
Thanks,
Nathan
You can tell Windows to automatically attach the debugger when a certain process is started (by specifying the process name in a registry setting).
The details are here:
http://msdn.microsoft.com/en-us/library/a329t4ed(v=vs.100).aspx
You'd be hard pushed to make use of the debugbreak command in the child process as the debug process is not yet attached.
However, there is another that may be of use. Seeing as your creating the process, you'll have the handle to it. So give the DebugBreakProcess function a whirl.

Resources