VS 2008 Attach to process disabled - visual-studio

I have used the attach to process feature of visual studio a number of times. However now when i try to attach to a process (dll) the Attach button is disabled. However if i select any other process except the managed one the Attach button is enabled! My problem is closely related to the problem described at the link below
VS attaching to process disabled
A picture of the dialog is attached.

This is almost certainly because there is already another debugger attached to the process - probably the currently running instance of Visual Studio but it may be another instance of Visual Studio, or another debugger entirely (such as WinDbg or a remote debugging session).
Check the "Processes" window (usually found under Debug -> Windows -> Processes) to see what processes Visual Studio is debugging.

Found the solution to the problem
How to step into C/C++ DLL from C# application while debugging
http://msdn.microsoft.com/en-us/library/605a12zt%28v=VS.90%29.aspx

Related

Attach to Visual Studio process by name

For the development I do, I often need to attach to a running process by name (usually a windows service running under a different user account). It is tedious to do:
Debug
Attach to Process...
Select Attach To to switch between Native and Managed code
(we use both in the same process so it's not set to automatic)
Scroll down to find it in the list
Hit Attach button
Agree to the confirmation to debug a windows service
Since it's always the same process, ideally I would like 2 buttons (macros?) on a custom toolbar. One that attaches for managed debugging and another that attaches for native debugging. In both cases, the process name is built into the macro.
Can someone point me to the right resources/documentation to set something like that up?
A Visual Studio macro that you can customize for your process name:
Attach the VS Debugger to IIS’s Worker Process in a single keystroke.
Debug Attach Manager 2012 extension for VS 2012 that "provides extended abilities to attach Visual Studio debuger to web application pools, windows services and other processes."

detach one process from visual studio debugger

My question is somewhat similar to this
"How to stop debugging (or detach process) without stopping the process?"
but i want to detach from one process.
for instance, I have a windows form app which i also attach to a windows service. I want to detach from only service (detach all will remove debugging from all executions and hence i won't be able to debug other application).
P.S: If possible please mention for visual studio 2008 and 2010.
In the Processes window (Debug -> Windows -> Processes), right-click on the name of the process you want to detach, and on the shortcut menu, click Detach Process.
Just wanted to share that the shortcut key combo (in VS2013) is Ctrl+Alt+Z to bring up the Process window. The window will only pop up if there is at least one process attached.
If you have Visual Studio Express, there is no Processes window and I did not realized how to detach only one process.
If you are doing Mixed Mode debugging then neither the Debug > Detach All option nor detaching as mentioned in Centro's answer in this thread would work.
I see the Debug > Detach All option or Detach Process option in Debug > Windows > Processes dialog, when I am debugging in Native only or Managed only mode.
I have tested this on Visual Studio 2005 at least for now.
Reference: https://developercommunity.visualstudio.com/t/cannot-detach-from-process-the-debugdetach-all-opt/225642

VS attaching to process disabled

A few days ago, the attach button in "Attach to process" dialogue became disabled in VS 2010 and VS 2008 likewise. At first I thought that it is just an extension I've installed in VS 2010 but then I noticed it is the same in VS 2008. The both VS's a re running in administrative mode and on Windows 7.
I looked around but I can't seem to find a solution to this.
If anybody has encountered an similar problem, a little help would do great.
Thanks upfront.
EDIT: Attached a picture of the dialogue!
Where it says
you should press 'Select' and ensure at least managed is ticked. (or choose automatic)
otherwise, the 'Attach' button will be disabled.
It could also be because there is already another debugger attached to the process - probably the currently running instance of Visual Studio but it may be another instance of Visual Studio, or another debugger entirely (such as WinDbg or a remote debugging session).
Check the "Processes" window (usually found under Debug -> Windows -> Processes) to see what processes Visual Studio is debugging.
Try stopping Visual Studio but don't close the process.
I have come across a weird situation under which Attach button was disabled. This was because of DebugDiag. Please refer the following thread for info.
I was trying to debug a windows service as described here and had the same issue. The solution was to run Visual Studio as Administrator and select to see processes from all users.

Attach existing VS.NET 2008 instance that's already debugging as JIT debugger

Is it possible to configure the VS.NET 2008 "Just-In-Time" Debugger dialog to show an existing instance of Visual Studio that's already attached to another process?
The scenario I have is an NUnit unit test that runs another process. When I'm debugging the unit test I want to automatically launch the debugger for the child process it runs as well. I pass a special parameter to the child process and the child calls Debugger.Launch(), which is all fine, but when the JIT debug dialog comes up it doesn't list the existing VS.NET instance - I can only open a new instance, which is quite inconvenient.
A debugger that's attached to another process, cannot attach to a secondary process. I think it is possible to have a debugger attached to multiple programs (you can debug multiple websites that are part of the same solution for instance).
Also, you cannot attach more than a single debugger to each process.

How to debug a process using Visual Studio?

If an application† crashes,
I hit "Debug" and Visual Studio is my currently registered Just-In-Time (JIT) debugger:
Visual Studio appears, but there's no way to debug anything:
I do not see any disassembly
I do not see any registers (assuming it runs on a CPU with registers)
The call stack is empty (assuming the CPU has a stack pointer)
I do not see any symbols (assuming it had any)
I do not see reconstructed source code from reflection (assuming it was managed)
Other JIT debugger products are able to show disassembly, but they are either command-line based (Debugging Tools for Windows), or do not support symbols (OllyDbg, Delphi). Additionally, my question is about debugging using Visual Studio, since I already have it installed, and it is already my registered JIT.
How do you debug a program using Visual Studio?
Alternatively: has anyone written a graphical debugger that supports the Microsoft symbol server?
† Not, necessarily, written in Visual Studio.
Edit: Changes title to process rather than application, since the latter somehow implies "my application."
Edit: Assume the original application was written in assembly language by Steve Gibson. That is, there is no source code or debug information. Visual Studio should still be able to show me an assembly dump.
Looking at the screenshot it appears that Visual Studio is currently debugging in Run mode - you need to break execution of the process before it makes sense to look at things like the call stack, etc...
To break execution of the process you either need to hit a breakpoint, or you can break execution of the process at any time by using the Pause / Break all toolbar item (Control + Alt + Break).
Then you should be able to access the following windows under the Debug -> Windows menu:
The disassembly window
The registers window
The call stack window
The modules window shows a list of loaded modules along with where their corresponding symbols are loaded from (if loaded)
Some other useful windows:
The processes window is useful if you are debugging more than one process at a time
The Threads window
The Memory window (there are four of them)
The Locals window
Some of these might not be visible by default depending on which window configuration you selected when you first started Visual Studio - if you can't find them then right click on the toolbar and goto customise to add them.
Visual studio doesn't reconstruct soucre code from disassembly - you really need to have the original source code available to you, otherwise the symbols almost certainly won't match the source code you are debugging.
If you are debugging unmanaged modules without source code then I recommend you at least try WinDbg - its user interface is a bit clunky at times, and it does have a steep learning curve, however it is a very powerful debugger supporting many features that Visual Studio doesn't - it may be more suited to the sort of debugging you need to do.
(Visual Studio is a fantastic debugger, however it's primarily used to debug modules where the source code is available and so it lacks certain features in favour of a better user experience).
Assuming this is your application that you wrote in VS, just press F5 to run the program and either use a breakpoint, or manually break the program to start debugging.
The problem in the last screenshot is that Visual Studio did not enter break mode automatically. That seems like a bug. If you hit the 'pause' button on the toolbar, it would enter break mode, giving you disassembly, and a callstack.
According to that last screenshot you were actually attached to the program ... the output windows shows it loaded stripped symbols for OLE and the crt.
You can debug a program with Visual Studio if you have the debug information available for this program. It's the difference between compiling a Release version (normally without debug information) and compiling a Debug version.
This dialog to debug a program is handy if you are testing the debug version of your self-written program. You can attach it "on-the-fly" to your Visual Studio debugger and look for the problem.
If it is not your program or it is your program, but does not provide debugging information which Visual Studio can understand, then you are out of luck.
Use menu Debug -> Windows -> Disassembly (I think the keyboard shortcut is Alt + 8, but I am configured for VC 6.0 bindings, because that's how I roll, and it may have changed).
You can get public symbols for the operating system from http://msdl.microsoft.com/download/symbols. Add it to the list in menu Tools -> Options -> Debugging -> Symbols -> Symbol file locations.
Also, make sure you are running in the same integrity level as the application. Or always run Visual Studio as Administrator.
I guess you are already in the Debug mode. The "Run" button is disabled. Just go to Debug -> windows -> Disassembly to view disassembly.

Resources