dotnet / dotnet/wpf

WPF Button rendering broken and crash with PublishTrimmed or PublishReadyToRun in .NET 8

Open
#11,436 2 comments 0 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

### Environment
- Visual Studio: Community 2026 (latest version)
- Target Framework: .NET 8.0-windows
- Project Type: WPF Application
- Deployment Mode: Self-contained

### Description
When publishing a WPF application as self-contained with "Trim unused code" (PublishTrimmed=true) OR "Produce ReadyToRun compilation" (PublishReadyToRun=true) enabled, the application exhibits rendering and runtime errors.

### Symptoms
1. Buttons are displayed incorrectly
2. Application crashes when clicking specific buttons

### Reproduction Steps
1. Create WPF application targeting .NET 8.0-windows
2. Configure self-contained deployment
3. Enable "Trim unused code" OR "Produce ReadyToRun compilation"
4. Publish and run the application
5. Observe button rendering issues and crashes

### Workaround
Works correctly with both options disabled:
- PublishTrimmed=false
- PublishReadyToRun=false

### Expected Behavior
Self-contained WPF deployments should work with trimming and ReadyToRun enabled.

### Reproduction Steps

### Reproduction Steps
1. Create WPF application targeting .NET 8.0-windows
2. Configure self-contained deployment
3. Enable "Trim unused code" OR "Produce ReadyToRun compilation"
4. Publish and run the application
5. Observe button rendering issues and crashes

### Expected behavior

### Expected Behavior
Self-contained WPF deployments should work with trimming and ReadyToRun enabled.

### Actual behavior

---

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.