If a binding expression error occur during debugging the error is logged into the Output window in Visual Studio. It looks something like this:
System.Windows.Data Error: BindingExpression path error: 'User' property not found
on 'MainPageVM' 'MainPageVM' (HashCode=38694667). BindingExpression: Path='User.FullName'
DataItem='MainPageVM' (HashCode=38694667); target element is 'System.Windows.Controls.TextBlock'
Name=''); target property is 'Text' (type 'System.String')..
Is there a way to treat this error as an unhandled exception instead? I don't want my Silverlight app to continue running if a binding error has occurred.
You can catch the trace errors.
(The listener must be in external dll.)
namespace CustomTracer
{
public class CustomTraceListener : TraceListener
{
public CustomTraceListener()
{
}
public override void Write(string message)
{
}
public override void WriteLine(string message)
{
if(Debugger.IsAttached)
Debugger.Break();
}
}
}
Add this to app.config
<system.diagnostics>
<sources>
<source name="System.Windows.Data" switchName="OnlyErrors" >
<listeners>
<add name="textListener" type="CustomTracer.CustomTraceListener,CustomTracer"/>
</listeners>
</source>
</sources>
<switches>
<add name ="OnlyErrors" value ="Error"/>
</switches>
</system.diagnostics>
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