I would like to log the DataBinding errors to a file. I Used the solution presented in this accepted anwser:
How can I turn binding errors into runtime exceptions?
I also tried this: http://msdn.microsoft.com/en-us/library/system.diagnostics.presentationtracesources.aspx
The problem is that it only works while running in the VS IDE. When I publish the app the errors are not caugth.
Does anybody know how to get the WPF Bindind errors and save to a file, by the published app, programatically, during runtime ?
I used a technique similar to the one described in the first link you provided. It can be resumed by the following steps:
TraceListener
that throws instead of loggingPresentationTraceSources.DataBindingSource
I tested with .NET Framework 4.0, 4.5 and 4.5.1; it works on both Debug
and Release
configurations.
Please check the complete solution I pushed on GitHub, it includes a demo application and a unit test project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With