Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4034972
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:02:22+00:00 2026-05-20T12:02:22+00:00

I am looking for an application-wide method of catching exceptions thrown by databound property

  • 0

I am looking for an application-wide method of catching exceptions thrown by databound property getters (and setters, but that’s doable without as much difficulty).

None of these events will catch exceptions thrown by getters:

 AppDomain.CurrentDomain.UnhandledException
 Application.Current.DispatcherUnhandledException
 Application.Current.Dispatcher.UnhandledException

Another idea is to use a custom binding class with an UpdateSourceExceptionFilter as described in this thread. Unfortunately this method only catches exceptions in property setters, not getters.

The final option I have seen is to use a PresentationTraceSources trace listener:

 PresentationTraceSources.Refresh();
 PresentationTraceSources.DataBindingSource.Listeners.Add(new PresentationLoggingTraceListener());
 PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Error;

This method does appear to do basically what I want. Unfortunately, it only gives me a string, not an Exception, meaning I would have to do a bit of parsing work to get at the actual error.

The TraceListener method would probably work in the end, but it seems a little hackish. Are there any other options that I am missing, or am I pretty much stuck with the TraceListener?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:02:23+00:00Added an answer on May 20, 2026 at 12:02 pm

    I would suggest an Aspect Oriented Programming (AOP) approach to this problem. It would allow you to inject code at compile time that wraps your getter with whatever you wish, in this case a try/catch and logging. The only one that I’ve worked with is PostSharp Laos, the free version of PostSharp http://www.sharpcrafters.com.

    I believe this is a good place to start, http://www.richard-banks.org/2009/02/aspect-oriented-programming.html, in that example he wraps setters with the ability to automatically call NotifyPropertyChanged. There are several other AOP projects out there you could also use but I’ve not used them. Here is a nice list: http://www.bodden.de/tools/aop-dot-net. I would suggest weave-based approaches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for an application that would lock my computer and display a screensaver
Looking for a Linux application (or Firefox extension) that will allow me to scrape
Looking to see if there's an existing method or application to increase display size
I am looking into an application that needs to check that emails are being
Borland's VCL library has application wide events that let me do some global keystroke
I have a confusion that MSWord is a MDI or SDI application. Looking at
I'm looking for application-wide access to raw keyboard events in OS X, either using
I'm starting a new application and looking at using an ORM -- in particular,
I have inherited a classic ASP application and looking through the code I see
Looking at the Single page application beta in the MVC 4 I don't see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.