Turn WPF Binding error into runtime exception. Not working on published Released app

前端 未结 2 2480
南笙
南笙 2021-02-20 18:25

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?

2条回答
  •  心在旅途
    2021-02-20 18:46

    I used a technique similar to the one described in the first link you provided. It can be resumed by the following steps:

    1. Derive a TraceListener that throws instead of logging
    2. Add your listener to PresentationTraceSources.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.

    Exception in Visual Studio

提交回复
热议问题