Debugging an application called from another in Visual Studio?
Asked Answered
S

5

6

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?

Serrell answered 24/3, 2013 at 21:35 Comment(0)
F
8

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.

Fourgon answered 24/3, 2013 at 21:36 Comment(5)
Is 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 etcSerrell
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.Fourgon
Sorry - I mean when the .NET Process is spawned can I automatically hook it?Serrell
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.Fourgon
Thanks. This answer / Debugger.Launch() best describes what I should. Thanks a bunch. :)Serrell
C
1

Debug -> Attach to process

Select the executable from the list.

Make sure to select the right code type with the Select.. button.

Cab answered 24/3, 2013 at 21:37 Comment(0)
C
1

Have you tried Debug -> Attach to Process?

Ref: http://msdn.microsoft.com/en-gb/library/vstudio/3s68z0b3.aspx

Coronal answered 24/3, 2013 at 21:37 Comment(0)
R
1

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

Raisaraise answered 24/3, 2013 at 21:38 Comment(0)
K
1

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.

Komi answered 25/3, 2013 at 12:29 Comment(1)
The problem is actually that one invokes the others with variable parameters. The state can only be known at run time.Serrell

© 2022 - 2024 — McMap. All rights reserved.