Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

WPF exceptions inside beginInvoke

Back to Forum: Tech Off
  • User profile image
    pompomJuice

    Hi there.

    I am sorry if this has been answered before, somehow I find it difficult to steer Google to give me answers with regards to the topic.

    I am currently "procedurally" creating a WPF app. I am aware that this raises red flags for all, but down here there is no proper training available for the poor with regards to new MS technologies.  I had difficulty grasping how I am going to create the kind of UI that was required within the expected timeline without training. Ok so that being out of the way this is my main problem:

    Every now and again I get the following exception on: _wpfApp.Run( _wndMain );

    An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

    Now, I have since figured out that this is sometimes caused by exceptions within those dispatch thingies. Now, "theoretically" I should not be writing code inside those dispatches that's complicated enough to cause exceptions. But unfortunately it just is not so simple for me in practice.  Maybe its because I am to lazy to spam 2 methods for basically every interaction with the UI, but I don't want to believe that.

    My question is, how can I get the debugger to actually break on the line of code that causes the exception instead of floating back to Application.Run. If I have suspicions on where the exception is located  I can always manually steer the debugger towards it, so why can’t the IDE do that for me. Why does it no "step to" the problem manually like I have to do? It's driving me crazy.

    Thanks for any help.

    Regards

  • User profile image
    wkempf

    Have you looked at the InnerException?  This will usually lead you to the actual issue.

  • User profile image
    Sven Groot

    Debug menu, Exceptions, for "Common Language Runtime Exceptions" check the "Thrown" checkbox. That'll cause the debugger to immediately break for all exceptions when they're thrown, even if they are handled somewhere.

  • User profile image
    pompomJuice

    Sven Groot said:

    Debug menu, Exceptions, for "Common Language Runtime Exceptions" check the "Thrown" checkbox. That'll cause the debugger to immediately break for all exceptions when they're thrown, even if they are handled somewhere.

    Thanks allot.

    I will test it out and see how it works Wink

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.