0

In my Silverlight project I have a thread that fires every x milliseconds. In this thread I was attempting to change the state of the application. This wasn't working and I didn't know why, so put a breakpoint in to the Timer callback. The breakpoint was hit, but the minute I attempted to change the state it just bailed out of the function (assuming an exception has been thrown).

I know why the error occurred - you can't change GUI stuff via a non-GUI thread.

My question is - how can I get Visual Studio to actually break when an exception like that occurs? (Rather than just silently bailing out, which doesn't notify me if there is a problem).

I've tried the "Break when exceptions cross AppDomain or managed / native boundaries", but that didn't have any effect.

Mark Ingram
  • 71,849
  • 51
  • 176
  • 230

1 Answers1

4

Can you change the break handling for InvalidOperationException so it breaks immediately rather than only if it's unhandled?

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Debug Menu -> Exceptions -> CLR Exceptions -> System -> System.InvalidOperationException: tick the checkbox in the "Thrown" column. You may get some false positives, but it should (I believe) catch the case you're interested in. – Jon Skeet Oct 09 '08 at 10:12
  • Thanks John - I knew there was a place to do that. It caught my exception - but not where I was expecting it! The problem was the UnhandledException event was firing, then attempting to display an alert box, which you can't do in non-GUI thread. – Mark Ingram Oct 09 '08 at 10:46