Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPF .exe published using PublishTrimmed fails to launch #50689

Closed
lutzroeder opened this issue Apr 3, 2021 · 7 comments
Closed

WPF .exe published using PublishTrimmed fails to launch #50689

lutzroeder opened this issue Apr 3, 2021 · 7 comments
Labels
area-AssemblyLoader-coreclr linkable-framework Issues associated with delivering a linker friendly framework untriaged New issue has not been triaged by the area owner

Comments

@lutzroeder
Copy link
Member

lutzroeder commented Apr 3, 2021

Description

When building a WPF .NET app using <PublishTrimmed> the resulting .exe fails to launch.

  1. Run dotnet new wpf -n TestApp
  2. Add to TestApp.csproj:
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>true</SelfContained>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <PublishTrimmed>true</PublishTrimmed>
    <PublishReadyToRun>true</PublishReadyToRun>
  1. Run dotnet publish
  2. Run bin\Debug\net5.0-windows\win-x64\publish\TestApp.exe
Faulting application name: WpfApp5.exe, version: 1.0.0.0
Faulting module name: KERNELBASE.dll, version: 10.0.19041.804
Exception code: 0xe0434352
Faulting application path: [...]bin\Debug\net5.0-windows\win-x64\publish\TestApp.exe.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Faulting package full name: 
Faulting package-relative application ID: 
 
Application: TestApp.exe
CoreCLR Version: 5.0.421.11614
.NET Version: 5.0.4
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException: The type initializer for 'System.Windows.Window' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Windows.FrameworkElement' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Windows.Documents.TextElement' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Windows.Documents.Typography' threw an exception.
 ---> System.IO.FileNotFoundException: 
File name: 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Configuration

.NET SDK (reflecting any global.json):
 Version:   5.0.201
 Commit:    a09bd5c86c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.201\

Host (useful for support):
  Version: 5.0.4
  Commit:  f27d337295

.NET SDKs installed:
  3.1.113 [C:\Program Files\dotnet\sdk]
  5.0.104 [C:\Program Files\dotnet\sdk]
  5.0.200 [C:\Program Files\dotnet\sdk]
  5.0.201 [C:\Program Files\dotnet\sdk]

@danmoseley

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Apr 3, 2021
@ThomasGoulet73
Copy link
Contributor

You can use this in your csproj:

    <ItemGroup>
        <TrimmerRootAssembly Include="System.Diagnostics.Debug" /> 
        <TrimmerRootAssembly Include="System.Runtime" /> 
        <TrimmerRootAssembly Include="System.Runtime.Extensions" />          
    </ItemGroup>

@marek-safar marek-safar added the linkable-framework Issues associated with delivering a linker friendly framework label Apr 4, 2021
@ghost
Copy link

ghost commented Apr 4, 2021

Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @tannergooding, @sbomer
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When building a WPF .NET app using <PublishTrimmed> the resulting .exe fails to launch.

  1. Run dotnet new wpf -n TestApp
  2. Add to TestApp.csproj:
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>true</SelfContained>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <PublishTrimmed>true</PublishTrimmed>
    <PublishReadyToRun>true</PublishReadyToRun>
  1. Run dotnet publish
  2. Run bin\Debug\net5.0-windows\win-x64\publish\TestApp.exe
Faulting application name: WpfApp5.exe, version: 1.0.0.0
Faulting module name: KERNELBASE.dll, version: 10.0.19041.804
Exception code: 0xe0434352
Faulting application path: [...]bin\Debug\net5.0-windows\win-x64\publish\TestApp.exe.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Faulting package full name: 
Faulting package-relative application ID: 
 
Application: TestApp.exe
CoreCLR Version: 5.0.421.11614
.NET Version: 5.0.4
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException: The type initializer for 'System.Windows.Window' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Windows.FrameworkElement' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Windows.Documents.TextElement' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Windows.Documents.Typography' threw an exception.
 ---> System.IO.FileNotFoundException: 
File name: 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Configuration

.NET SDK (reflecting any global.json):
 Version:   5.0.201
 Commit:    a09bd5c86c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.201\

Host (useful for support):
  Version: 5.0.4
  Commit:  f27d337295

.NET SDKs installed:
  3.1.113 [C:\Program Files\dotnet\sdk]
  5.0.104 [C:\Program Files\dotnet\sdk]
  5.0.200 [C:\Program Files\dotnet\sdk]
  5.0.201 [C:\Program Files\dotnet\sdk]

@danmoseley

Author: lutzroeder
Assignees: danmoseley
Labels:

linkable-framework, untriaged

Milestone: -

@ghost
Copy link

ghost commented Apr 4, 2021

Tagging subscribers to this area: @vitek-karas, @agocke, @CoffeeFlux, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When building a WPF .NET app using <PublishTrimmed> the resulting .exe fails to launch.

  1. Run dotnet new wpf -n TestApp
  2. Add to TestApp.csproj:
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>true</SelfContained>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <PublishTrimmed>true</PublishTrimmed>
    <PublishReadyToRun>true</PublishReadyToRun>
  1. Run dotnet publish
  2. Run bin\Debug\net5.0-windows\win-x64\publish\TestApp.exe
Faulting application name: WpfApp5.exe, version: 1.0.0.0
Faulting module name: KERNELBASE.dll, version: 10.0.19041.804
Exception code: 0xe0434352
Faulting application path: [...]bin\Debug\net5.0-windows\win-x64\publish\TestApp.exe.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Faulting package full name: 
Faulting package-relative application ID: 
 
Application: TestApp.exe
CoreCLR Version: 5.0.421.11614
.NET Version: 5.0.4
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException: The type initializer for 'System.Windows.Window' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Windows.FrameworkElement' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Windows.Documents.TextElement' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Windows.Documents.Typography' threw an exception.
 ---> System.IO.FileNotFoundException: 
File name: 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Configuration

.NET SDK (reflecting any global.json):
 Version:   5.0.201
 Commit:    a09bd5c86c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.201\

Host (useful for support):
  Version: 5.0.4
  Commit:  f27d337295

.NET SDKs installed:
  3.1.113 [C:\Program Files\dotnet\sdk]
  5.0.104 [C:\Program Files\dotnet\sdk]
  5.0.200 [C:\Program Files\dotnet\sdk]
  5.0.201 [C:\Program Files\dotnet\sdk]

@danmoseley

Author: lutzroeder
Assignees: -
Labels:

area-AssemblyLoader-coreclr, linkable-framework, untriaged

Milestone: -

@vitek-karas
Copy link
Member

This is basically a duplicate of dotnet/sdk#14261 which was "moved" to the dotnet/wpf repo dotnet/wpf#3811. Currently, by default, WPF apps are basically broken when trimmed. And even if that is fixed (dotnet/sdk#14261 has some discussion how to do that), the size wins are not that good.

@eerhardt
Copy link
Member

eerhardt commented Apr 6, 2021

@vitek-karas - can we close this as a duplicate of dotnet/wpf#3811?

@agocke
Copy link
Member

agocke commented Apr 7, 2021

Yup, I think closing as a dup is correct. There's also a bug about adding a warning about trimming at dotnet/sdk#16716

@agocke agocke closed this as completed Apr 7, 2021
@ghost ghost locked as resolved and limited conversation to collaborators May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-AssemblyLoader-coreclr linkable-framework Issues associated with delivering a linker friendly framework untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

8 participants