Home How to get WPF application to break in code?
Reply: 0

How to get WPF application to break in code?

user1366
1#
user1366 Published in May 28, 2018, 9:48 am

When debugging in .NET, I really enjoy being able to step directly into my code when an error is triggered at a certain location. When programming a WPF application, however, I can't seem to access this feature.

Consider this simple program:

sub breakMe()
   dim badObject as Object = nothing
   getObjectString(badObject)
 end sub

sub getObjectString(whatObj as object)
   whatObj.toString
 end sub

If this were a winforms project, the debugger would break right on the "whatObj.toString" line and I could step into the call stack there and jump around into any prior procedures and check object values throughout. With WPF, however, there is an unhandled exception triggered that makes this impossible.

I've read many, many examples of ways that you can add handlers to WPF which allow you to custom handle exceptions so that you can view the relevant stack trace. While helpful, this is still not nearly as good as being actually able to step into the code exactly where it breaks and view object values.

You could add try blocks to achieve the desired result, but that would obviously be impractical to do throughout the project, and it seems like there should be an easy way to do this. Perhaps by forcing the debugger to simply bypass the handlers for the WPF graphical components?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.446214 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO