AutoCAD 2025 System.Windows.Data Error in visual studio output window

AutoCAD 2025 System.Windows.Data Error in visual studio output window

oneMSN
Advocate Advocate
281 Views
2 Replies
Message 1 of 3

AutoCAD 2025 System.Windows.Data Error in visual studio output window

oneMSN
Advocate
Advocate

We used to be able to suppress these error message by editing the acad.exe.config and adding the following:

<system.diagnostics>
    <sources>
      <source name="System.Windows.Data" switchName="SourceSwitch">
        <listeners>
          <remove name="Default" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

 

But that does not appear to work for AutoCAD 2025, and the snow of messages is giving me a sore head when I have to wade through the output looking for messages of 'real' interest.  is there a new way to suppress these pointless error messages (pointless as there is nothing to be done about them!)

0 Likes
Accepted solutions (1)
282 Views
2 Replies
Replies (2)
Message 2 of 3

OysteinW
Advocate
Advocate
Accepted solution

This should do the trick:

 void IExtensionApplication.Initialize()
 {
   if (PresentationTraceSources.DataBindingSource.Listeners.Count > 0)
   {              
      PresentationTraceSources.DataBindingSource.Listeners.Remove("Default");
   }
   PresentationTraceSources.DataBindingSource.Listeners.Add(new 
   FilteredTraceListener());
}
 
public class FilteredTraceListener : DefaultTraceListener
{
    public override void Write(string? message)
    {
        if (!IgnoreMessage(message))
        {
            base.Write(message);
        }
    }

    public override void WriteLine(string? message)
    {
        if (!IgnoreMessage(message))
        {
            base.WriteLine(message);
        }
    }

    private bool IgnoreMessage(string? message)
    {
        // Define logic to determine if the message should be ignored
        return message?.Contains("Cannot find source for binding")==true ||message?.Contains("System.Windows.Data Error")==true ? true: false;
    }
} 
Message 3 of 3

oneMSN
Advocate
Advocate

Worked like a charm, thank you.