friends .
i am debugging WPF data binding according to this.
i added PresentationTraceSources.TraceLevel in my xaml.
<Window …
xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
/>
<TextBlock Text="{Binding Path=Caption, diagnostics:PresentationTraceSources.TraceLevel=High}" … />
if i launch my WPF application in VS2008 by press F5, in output window , i did see the data binding detail messages:
System.Windows.Data Warning: 47 : Created BindingExpression (hash=25209742) for Binding (hash=3888474)
…
System.Windows.Data Warning: 91 : BindingExpression (hash=25209742): GetValue at level 0 from Star (hash=31609076) using RuntimePropertyInfo(Caption): ‘ ‘
System.Windows.Data Warning: 71 : BindingExpression (hash=25209742): TransferValue – got raw value ‘ ‘
System.Windows.Data Warning: 78 : BindingExpression (hash=25209742): TransferValue – using final value ‘ ‘
but if i run the app directly and attach VS2008 to process, there is no data binding message in output window.
why these trace message don’t show when i attached to process? how to get these data binding trace messages ?
(in production environment ,my app is launched by another exe, and all i can do is attach to process).
This is purely conjecture.
When you start the application from Visual Studio with F5, it has a console output Window, and presumably during intialization of the PresentationTraceSources a default ConsoleTraceListener is added which is able to hook up to the Visual Studio output console.
When you start the application outside of a Debugger then perhaps it doesn’t/can’t add a ConsoleTraceListener successfully because there isn’t one around…..thus when you attach your process to the debugger, the WPF Data Binding trace sources aren’t redirected to the Output Window.
Maybe you can attach a console listener after you have attached to the process.
Finally, did use the App.Config mentioned in the Bea Stollnitz/Costa article to get output directed to a Text file ? …. did that work?
Might be worth checking what the value of System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level is after you attach to the process too.
This goes into a bit more detail on the whole TraceSources mechanism:
http://blogs.msdn.com/b/mikehillberg/archive/2006/09/14/wpftracesources.aspx