🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
WPF Debugger
This page was created by Hans.karlsen on 2019-04-29. Last edited by Wikiadmin on 2026-07-29.

You can open the MDriven runtime WPF debugger from your own WPF application to inspect and debug expressions against the application's current EcoSpace; this page is for developers embedding that debugger in a WPF application.

What the runtime WPF debugger does

The runtime debugger is MDriven.WPF.Debugger.OCLRuntimeDebuggerWPF. Create it with the application's current EcoSpace and show it as a WPF window.

Use this debugger when you need to investigate runtime expression behavior in an application that uses MDriven WPF UI. For debugging from within MDriven Designer, use OCL Debugger instead. For inspecting or changing the MDriven model itself, see Documentation:Using the model debugger to change the model itself.

Add the debugger to a WPF application

Create and show the debugger at the point where your application has a current EcoSpace.

  1. Ensure that the WPF dequeuer is active.
  2. Create OCLRuntimeDebuggerWPF with GA.Singleton.GetCurrentEcoSpace().
  3. Call Show() to open the debugger window.
Eco.WPF.WPFDequeuer.Active = true;

var wpfdebugger = new MDriven.WPF.Debugger.OCLRuntimeDebuggerWPF(
    GA.Singleton.GetCurrentEcoSpace());

wpfdebugger.Show();

Eco.WPF.WPFDequeuer.Active = true is required by the debugger. It is also required for MDriven WPF UI so that derivations displayed on screen are evaluated.

The debugger receives the current EcoSpace through GA.Singleton.GetCurrentEcoSpace(). In practice, this means that you should open it only after the application has established the EcoSpace you intend to inspect.

Support a WinForms application that hosts WPF windows

If your application object is a WinForms application and the application uses WPF windows, enable modeless keyboard interoperability for each WPF window. Without this setup, keyboard input and events may not work correctly in the true WPF forms running in the WinForms environment.

Add the following code in addition to the basic debugger setup:

Eco.WPF.WPFDequeuer.Active = true;

var wpfdebugger = new MDriven.WPF.Debugger.OCLRuntimeDebuggerWPF(
    GA.Singleton.GetCurrentEcoSpace());

// Required when the WinForms application hosts WPF forms.
AutoFormWPF.OnNewAutoFormWPFCreated += (s, e) =>
{
    System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(
        e.AutoFormWPF);
};

System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(
    wpfdebugger);

wpfdebugger.Show();

The event handler applies EnableModelessKeyboardInterop to every new AutoFormWPF. The second call applies the same setting to the debugger window itself.

Application setup Required setup
WPF application using the runtime debugger Set Eco.WPF.WPFDequeuer.Active = true, create OCLRuntimeDebuggerWPF with the current EcoSpace, then call Show().
WinForms application that uses WPF forms, including the runtime debugger Use the WPF setup and call ElementHost.EnableModelessKeyboardInterop for each new AutoFormWPF and for the debugger window.

Example: open the debugger from application code

The following example opens a debugger against the current EcoSpace. In a mixed WinForms/WPF application, retain the interoperability lines shown in the previous section.

private void OpenRuntimeDebugger()
{
    Eco.WPF.WPFDequeuer.Active = true;

    var debugger = new MDriven.WPF.Debugger.OCLRuntimeDebuggerWPF(
        GA.Singleton.GetCurrentEcoSpace());

    debugger.Show();
}

Scope and related debugging tools

This page covers opening the WPF debugger in a running application. It does not describe the Designer debugging workflow or model maintenance workflow:

For context on the WPF runtime client and its ViewModel-based information tree, see Documentation:Windows WPF client. For prototyping-engine background, see Documentation:WECPOF.

See also