Share via


Debugging MCML

Windows Media Center Markup Language (MCML) supports debug tracing, and the Preview Tool supports runtime exception dumping.

MCML supports the ability to generate traces from your rule declarations by using the DebugTrace element. DebugTrace produces debug traces, which include dumping any state in your UI that is reachable from an object path. This feature is useful for checking whether rules are running as expected and for dumping an intermediate UI state.

The Preview Tool supports dumping unhandled run-time exceptions. At parse time, the platform will attempt to verify the markup to ensure a stable run time. Run-time exceptions are not hidden because they indicate a design error (either in markup or code). The Preview Tool signals errors as debug traces.

To use these features, you must run a debug trace monitor. Running under a debugger (such as Visual Studio) displays traces in the debugger's output window. The disadvantage of this is that you must start your application under the debugger or attach it at run time (for more information, see Attaching a Debugger to a Windows Media Center Application using Visual Studio). An alternative is to run a stand-alone debugging monitor, such as the Debug Monitor tool (Dbmon.exe), which is available in the Windows SDK.

To help debug complex MCML, use the Debug Monitor tool available in the Platform SDK. Insert a DebugTrace statement to understand the flow of execution or to generate intermediate values of parameters or locals, as shown in the example below.

Note .NET Framework events and exceptions cannot be caught and handled directly in MCML markup. However, you can create a .NET Framework class to catch exceptions in your Windows Media Center application and expose exceptions to MCML using standard mechanisms, such as the IPropertyObject interface.

<Rule>
  <Conditions>
  .
  .
  .
  </Conditions>
  <Actions>
    <DebugTrace Message="'Value'={0}">
      <Params>
        <ObjectPath ObjectPath="[Value]" />
      </Params>
    </DebugTrace>
    .
    .
    .
  </Actions>
  .
  .
</Rule>

Sample Explorer

  • Markup > Debugging

See Also