user1378544
user1378544

Reputation: 21

Debug application running outside Visual Studio

I develop C# applications using VS 2010 Ultimate. Usually, those applications run for long time, without user interaction and, of course, they usually have bugs inside.

Unfortunately, often the application crashes randomly and you just can't reproduce the error. Also sometimes I only have the message "The application has stopped working" with no more informations.

I can install Visual Studio on the machine of the customer, but I can't let him run VS and compile/start the source code in debug mode! What I need is to start VS after the application was started and crashed. It seems to be possible to do this, in fact when an exception happens at runtime, Windows ask you "do you want to debug with VS?", but if I answer YES, then VS starts but simply I can't see the source code (it is on the pc as well), thus I can't inspect the row of code that is causing the exception. VS just tells me "source code not available". Actually, I can't imagine how Windows could start VS and know where the source code of the crashed application is!

Does anyone knows how does this debugging scenario is intended to work, and how to configure it??

Thanks a lot, Simone

Upvotes: 2

Views: 1833

Answers (3)

Lander
Lander

Reputation: 3437

To debug from an already-running Visual Studio instance, select the "Debug" menu item, then "Attach to Process..."

Attach to Process

Next, select the executable from the list, press "Attach" (or double-click), and you are now debugging the application. When you select "Yes" and Windows says that source code is not available, this most likely means that the PDB wasn't able to be loaded, so make sure that you have loaded the symbols for the module by examining it in the "Modules" window pane.

Upvotes: 1

Rockstart
Rockstart

Reputation: 2377

Windbg debugging tool solves the purpose.

Take dump of the process state and start analyzing with windbg. It gives you the exception information

Upvotes: 1

Ernestas Romeika
Ernestas Romeika

Reputation: 171

If you want to catch errors while running compiled program, you should use some sort of logging mechanism. These days you don't have to write it on your own, there's a great opensource logging engine designed for .NET applications, it's called NLog. It's capable of saving logs into files, emails, console or database, pretty much all you can want :).

Hope this helps :)

Upvotes: 0

Related Questions