I have a lobby application which invokes a client-application (think: League of Legends). They're two separate applications and the first invokes the second from itself - how can I get Visual Studio to debug this application as well?
5 Answers
You simply need to launch a separate Visual Studio, and then use Debug | Attach to Process to attach to the other process. The trick is using two Visual Studios.

- 104,400
- 10
- 158
- 276
-
1Is there a way to automatically detect the hook when it launches? And does this give me access to the full .NET debugging tools? It seems like this wouldn't give me source code breakpoints etc – Vaughan Hilts Mar 24 '13 at 21:40
-
I'm not sure what you mean by "detect the hook", but you certainly get all the source code breakpoints and so on. The only thing is that if the other program is running as a different account (e.g. as a service) you have to select "show processes from all users" when viewing the list of processes that you can attach to. – Matthew Watson Mar 24 '13 at 22:56
-
Sorry - I mean when the .NET Process is spawned can I automatically hook it? – Vaughan Hilts Mar 24 '13 at 22:59
-
Ah I see. Unfortunately, no. Sometimes I've had to put a `MessageBox.Show("Attach now!");` in the start of my `Main()` method when I needed to attach to debug the startup code. Other times, it doesn't matter. – Matthew Watson Mar 24 '13 at 23:03
-
Thanks. This answer / Debugger.Launch() best describes what I should. Thanks a bunch. :) – Vaughan Hilts Mar 24 '13 at 23:08
Debug -> Attach to process
Select the executable from the list.
Make sure to select the right code type with the Select.. button.

- 48,127
- 24
- 147
- 185
Have you tried Debug -> Attach to Process
?
Ref: http://msdn.microsoft.com/en-gb/library/vstudio/3s68z0b3.aspx

- 16,093
- 1
- 29
- 48
Like Matthew said Debug|Attach to process. If the other application is in a different service you might also want to look into remote debugging

- 8,707
- 2
- 42
- 50
The other answers are correct, but I just wanted to add another approach:
If you add both projects to a single Visual Studio Solution, you could:
Right-click the solution -> Properties -> Common Properties -> Startup Project
There you would select Multiple startup projects
and select both the Lobby and the Client applications.
That way you can debug several VS projects without having to run several VS instances.

- 666
- 6
- 16
-
The problem is actually that one invokes the others with variable parameters. The state can only be known at run time. – Vaughan Hilts Mar 25 '13 at 14:55