openclaw-windows-node/docs/XAML_COMPILER_BUG.md
Scott Hanselman c658b1f517 Organize docs and add Windows Node architecture roadmap
- Move CODE_REVIEW.md, TEST_COVERAGE.md, XAML_COMPILER_BUG.md to docs/
- Add WINDOWS_NODE_ARCHITECTURE.md - comprehensive plan for evolving
  tray app into a first-class Windows node with canvas, camera, screen
  capture, and more
2026-02-01 21:26:10 -08:00

2.2 KiB

WinUI 3 XAML Compiler Bug Report: Silent Crash on Type Mismatch

Summary

The WinUI 3 XAML compiler (XamlCompiler.exe) crashes with exit code 1 and produces no error message when the XAML root element type doesn't match the code-behind base class. This creates a frustrating debugging experience as developers receive no indication of what's wrong.

Reproduction

Minimal repro: D:\github\XamlCompilerCrashRepro.zip (6 files, ~2KB)

Steps

  1. Create a WinUI 3 project with WinUIEx package
  2. Create MainWindow.xaml using <Window> as root:
    <Window x:Class="CrashRepro.MainWindow" ...>
    
  3. Create MainWindow.xaml.cs inheriting from WindowEx:
    public sealed partial class MainWindow : WindowEx { ... }
    
  4. Run dotnet build

Expected

Clear error message like: "Type mismatch: XAML root element 'Window' doesn't match code-behind base class 'WinUIEx.WindowEx'"

Actual

error MSB3073: The command "XamlCompiler.exe input.json output.json" exited with code 1.

No output.json file is created. No additional error details.

Environment

Component Version
Windows App SDK 1.6.250602001 (also 1.8.x)
WinUIEx 2.5.0+
.NET 9.0
OS Windows 11 (ARM64 and x64)

Workaround

Ensure XAML and code-behind types match:

Option A: Both use Window

<Window x:Class="...">
public partial class MainWindow : Window

Option B: Both use WindowEx

<winex:WindowEx x:Class="..." xmlns:winex="using:WinUIEx">
public partial class MainWindow : WindowEx

Impact

  • Severity: Medium-High (blocks development, wastes debugging time)
  • Discoverability: Very poor (no error message)
  • Affected scenarios: Any derived Window type (WindowEx, custom base classes)

This may be related to existing XAML compiler issues around error reporting:

Suggested Fix

The XAML compiler should:

  1. Detect when the partial class base type differs from the XAML root element
  2. Produce a clear error message with file/line information
  3. Write error details to output.json even on failure