Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
PresentationTraceSources Class

Provides debug tracing support that is specifically targeted for Windows Presentation Foundation (WPF) applications. This is an abstract class.

Namespace:  System.Diagnostics
Assembly:  WindowsBase (in WindowsBase.dll)
Visual Basic (Declaration)
Public NotInheritable Class PresentationTraceSources
Visual Basic (Usage)
You do not need to declare an instance of a static class in order to access its members.
C#
public static class PresentationTraceSources
Visual C++
public ref class PresentationTraceSources abstract sealed
JScript
public final class PresentationTraceSources
XAML
You cannot directly create an instance of this class in XAML.

Debug tracing is only available when a WPF application is running in full trust mode.

In order to enable tracing, you first must set a registry key, then you must configure trace sources.

  • To create the registry key, set a “ManagedTracing” reg_dword value to 1 under “HKeyCurrentUser\Software\Microsoft\Tracing\WPF”.

  • To configure trace sources, create an application config file. This file has a .config extension, for example, XamlPad.exe.config.

Achieving optimal application performance requires forethought in application design and an understanding of best practices for Windows Presentation Foundation (WPF) application development. For more information, see Optimizing WPF Application Performance.

WPF Performance Profiling Tools

WPF provides a suite of performance profiling tools that allow you to analyze the run-time behavior of your application and determine the types of performance optimizations you can apply. The following table lists the five performance profiling tools that are included in the Windows SDK tool, WPFPerf:

Tool

Description

Event Trace

Use for analyzing events and creating event log files.

Perforator

Use for analyzing rendering behavior.

ETW Trace Viewer

Record, display, and browse Event Tracing for Windows (ETW) log files in a WPF user-interface format.

Visual Profiler

Use for profiling the use of WPF services, such as layout and event handling, by elements in the visual tree.

Working Set Viewer

Use for analyzing the working set characteristics of your application.

The Visual Profiler tool suite provides a rich, graphical view of performance data. In this screenshot, the CPU Usage section of the Visual Profiler gives you a precise breakdown of an object's use of WPF services, such as rendering and layout.

Visual Profiler display output
Visual Profiler display output

For more information on WPF performance tools, see Performance Profiling Tools for WPF.

The following sample configuration file enables tracing of animations, writing the output to a text file called "debug.txt".

<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.Windows.Media.Animation"
switchName="SourceSwitch" >
        <listeners>
          <add name="textListener" />
        </listeners>
      </source>
    <switches>
      <add name="SourceSwitch" value="All" />
    </switches>
    <sharedListeners>
      <add name="textListener"
           type="System.Diagnostics.TextWriterTraceListener"
           initializeData="Debug.txt" />
    </sharedListeners>
    <trace autoflush="true" indentsize="4"></trace>
  </system.diagnostics>
</configuration>
System..::.Object
  System.Diagnostics..::.PresentationTraceSources
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows Vista

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker