Tuesday, January 27, 2009

How to find out what that XamlParseException really means using MarkupSource tracing

It's sometimes pretty difficult to work out what the XamlParseException thrown when your app starts really means. WPF Markup tracing logs everything in the output window as the XAML is loaded - this nearly always gets you to the source of the problem.



You can turn it on like this:
public Window1()
{
    PresentationTraceSources.Refresh();
    PresentationTraceSources.MarkupSource.Switch.Level = SourceLevels.All;
    PresentationTraceSources.MarkupSource.Listeners.Add(new DefaultTraceListener());
    ...
}




0 comments: