Skip to content

Empty WPF app crashes when published as a self-contained single file on .NET 11 Preview 7 #11842

Description

@FIFER-Mods

Description

A new empty WPF application targeting .NET 11 crashes on startup when published as a self-contained single-file application.

The failure occurs both with and without IncludeNativeLibrariesForSelfExtract=true. Ordinary non-single-file self-contained publishing works correctly.

This appears related to:

PR #11575 changed DirectWriteForwarder.dll and System.Printing.dll from pure MSIL to IJW mixed-mode assemblies. PR #11664 fixed ordinary self-contained publishing by packaging ijwhost.dll as a native runtime asset, but single-file publishing still bundles DirectWriteForwarder.dll and it fails during startup.

Reproduction Steps

Using .NET SDK 11.0.100-preview.7.26381.103:

dotnet new wpf -n WpfSingleFileRepro -f net11.0
cd WpfSingleFileRepro

dotnet publish -c Release -r win-x64 --self-contained true `
  -p:PublishSingleFile=true `
  -p:IncludeNativeLibrariesForSelfExtract=true `
  -o .\publish-single

.\publish-single\WpfSingleFileRepro.exe

Expected behavior

The empty WPF application should start and display its window.

Actual behavior

The process terminates during System.Windows.Application initialization with exit code 0xE0434352:

Unhandled exception. System.TypeInitializationException:
The type initializer for 'System.Windows.Application' threw an exception.

 ---> System.TypeInitializationException:
 The type initializer for '<Module>' threw an exception.

 ---> System.BadImageFormatException:
 File name: '...\publish-single\DirectWriteForwarder.dll'

   at System.Windows.Application.ApplicationInit()
   at System.Windows.Application..ctor()
   at WpfSingleFileRepro.App.Main()

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

SDK: 11.0.100-preview.7.26381.103
Runtime: 11.0.0-preview.7.26381.103
MSBuild: 18.10.0-1.26381.103
OS: Windows 11, build 10.0.26200

Other information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProduct bug (most likely)Cost:MWork that requires one engineer up to 2 weeksPriority:1Work that is critical for the release, but we could probably ship withoutarea-NetSDKregressionstatus: This issue is a regression from a previous build or release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions