What is the advantage of "attach to process" over "Start Debugging"?

I am new to programming. I know I was just starting to debug before. Perhaps starting debugging for a small application is better to develop.

I found that Visual Studio IDE provides a different method of attaching to use process. When and why should I use attach debugging?

Such as multi-threaded application debugging. Debug Client / Service Application. etc. Thanks.

+2


a source to share


4 answers


Process binding is useful if you don't want to debug right from starting a process. For example, debugging usually slows down execution, so it's faster to launch the application, get it to the state where the error appears, and then attach the debugger.



It is also useful if you already have external process launchers that you do not want or cannot import into the IDE.

+2


a source


Sometimes you need to debug a process started by another program.

For example, you need a reliable solution, and to protect against access violations, memory leaks, and other barely recoverable material, you have a main program and several working programs. The master program starts the run program and transfers the parameters to it. How do you debug a working program that is not meant to be run by anything other than the main program?

You are using "attach to process for this".



You usually do it like this: insert an instruction that blocks the working program for some time - for example, call Sleep()

for 15 seconds. Then ask the wizard to run the work program. When the work program is running, it locks up and you now have 15 seconds to connect to it.

This way you can debug just about any problem - early startup problems, incorrect parameters, etc. that you can't reproduce with "run with debugging".

+3


a source


Start Debugging with VS starts a VS web server instance and attaches a debugger to it.

Process binding allows you to attach to any process and debug it, typically you do this in your w3wp.exe instance by running your code in IIS

+2


a source


Process binding is mainly used when you cannot launch your application from Visual Studio.

For example, if it's a service or if it's a process that has been running for a long time and now you want to start debugging it.

Sometimes you also want to debug a remote process and not on your computer - and you can do this using attach on the process.

+2


a source







All Articles