1

I have a VS2012 solution and WPF application, runs without exception in release and debug mode, but if I try to profile it the application crashes when I perform some UI actions (opening VMs, their view controls etc...)

Is there anyway to debug the exception when the application is ran in profiling mode?

Meirion Hughes
  • 24,994
  • 12
  • 71
  • 122
  • Problem disappeared after Update 2 for Visual Studio 2012 – Meirion Hughes Apr 10 '13 at 10:47
  • IMHO, if the reason you're profiling is to find "bottlenecks" (as opposed to just measuring), the best way is to *use the debugger*. As for example in [*this answer*](http://stackoverflow.com/a/927773/23771) where there's a 43x speedup. It's like a dogsled compared to a Bentley. Which would you rather have in the Arctic? – Mike Dunlavey Apr 10 '13 at 13:15

2 Answers2

0

You can always attach debugger to proces. Just open Debug->Attach to proces. If you want to break on any exception just press Ctrl+Alt+E and select proper option. If exception happen not in your code you could try to load pdb for selected dll.

Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116
0

No. There's not a lot of reason for an app to fail only when it is being profiled. It is usually something simple, like the working directory being different so your app will fall over when it does something unwise like trying to open a file with a relative path name. And no try/catch to handle the missing file problem.

What you need to focus on is what will happen when your app runs on the user's machine and crashes like this. Without a profiler but the very same problem of not knowing why it crashed. You'll need to spend a bit of time writing code that reports unhandled exceptions. Write an event handler for the AppDomain.CurrentDomain.UnhandledException event. Log or display the value of e.ExceptionObject.ToString(). Now you've got a good exception message and the Holy Stack Trace that shows you exactly how your program ended up crashing. Almost always good enough to figure out a small change in your code to prevent the crash. Or a better way to help the user's IT staff to fix the problem.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536