I am writing a VSPackage and want to support starting multiple debugger sessions with a single keypress. Does anyone have any insight into how I can get access to another process's IServiceProvider? Each debugging session runs in it's own Visual Studio process instance.
I'm targeting Visual Studio 2013
Kirill’s blog post outlines how to connect to another instance of VS here:
https://blogs.msdn.microsoft.com/kirillosenkov/2011/08/10/how-to-get-dte-from-visual-studio-process-id/
You can talk from another process to VS through all of the interfaces in the EnvDTE.dll once you have the DTE object from the Running Object Table.
Related
When I try to open two projects in two different instances of Visual Studio and run both of them locally in debug mode at the same time (say, a web application and the backend WebService that it uses) I get the error "Unable to start debugging on the web server. A debugger is already attached"
No one else in the office is able to do it either, except for one person, who can't figure out why it only works for him. The virtual directories in my computer's IIS seem to be set up the same way as his (I don't know about the settings).
I was also able to debug from two instances of VS at once at my previous job, so something about the setup here must be different.
I figured it out. Each project needs to be set to a different Application Pool. Found the answer here.
Since the same AppPool was being used by both the Web Application and Web Service, the same process hosted both. That is why as I had already attached the process in one instance of Visual Studio, I could not attach it in the second instance of Visual Studio.
Changing the AppPool had the effect of both being hosted in different host processes and hence they could now be debugged using different instances of Visual Studio.
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."
Can anyone tell me how to effectively use w3wp.exe to debug sharepoint applications?
If you are are running SharePoint on your development machine where you have Visual Studio installed - you can attach the debugger to the w3wp process, then breakpoints in your code will be hit when you 'touch' them from the web interface.
How to connect the debugger - good description in the MSDN article here http://msdn.microsoft.com/en-us/library/ff650703.aspx#Performing_Manual_Debugging
If you want to debug your bespoke application that sits within sharepoint via Visual studio i would recommend that you download WSP builder it has dubugging options within it. I'm sure this does the same thing as the post above but it also has sharepoint related things within it that may be of use.
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
Sometimes I experience Visual Studio 2010 being very sluggish. I have some plugins, like ReSharper for example, that I think could be the culprit.
It would be nice if I could see the processes under visual studio to see what is using up all the CPU. Basically what I am looking for is a Task Manager just like the one in Google Chrome but for Visual Studio. I searched the internet and came up with nothing.
Unlike Chrome, Visual Studio does not use multiple processes. (Except when debugging applications)
Using Process Explorer you can double click on your devenv.exe process, then under the Threads tab you can inspect, suspend or terminate (I wouldn't recommend the latter) threads belonging to addons, for example, VAssistX threads generally have a start address somewhere in the va_x.dll region.