Running my trimmed WPF .NET 5.0 application results in exception code 0xe0434352
See original GitHub issueProblem
I saw a lot of other issues where people seem to have issues with running a WPF app with PublishTrimmed=true.
For most of the issues the fix was to add the following item group to the .csproj file:
<ItemGroup>
<TrimmerRootAssembly Include="System.Collections" />
<TrimmerRootAssembly Include="System.Runtime" />
<TrimmerRootAssembly Include="System.Runtime.Extensions" />
<TrimmerRootAssembly Include="System.Runtime.InteropServices" />
<TrimmerRootAssembly Include="System.Runtime.CompilerServices.VisualC" />
</ItemGroup>
For my project however this doesn’t seem to work. When I start my .exe file nothing happens, the only thing I see is an exception in the windows event log:
Faulting application name: DeveImageOptimizerWPF.exe, version: 1.0.523.0, time stamp: 0x605138bc
Faulting module name: KERNELBASE.dll, version: 10.0.19041.964, time stamp: 0x812662a7
Exception code: 0xe0434352
Fault offset: 0x0000000000034b89
Faulting process id: 0x4b0c
Faulting application start time: 0x01d73eed93cbf116
Faulting application path: C:\Users\******\Downloads\DeveImageOptimizerWPF_win-x64_trimmed\DeveImageOptimizerWPF.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 27f3e7c5-9bec-47cc-9b0d-e86f9991dfbc
Faulting package full name:
Faulting package-relative application ID:
My application
My build command:
dotnet publish .\DeveImageOptimizerWPF\DeveImageOptimizerWPF.csproj -r win-x64 -c Release -o "DeveImageOptimizerWPF\bin\Release\net5.0-windows\win-x64\publishtrimmed\" /p:PublishSingleFile=true /p:SelfContained=true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=true
Build artifacts:
(If you download the trimmed .exe file the error can easily be reproduced) https://github.com/devedse/DeveImageOptimizerWPF/actions/runs/803276315#artifacts
csproj:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Running my trimmed WPF .NET 5.0 application results in ...
NET 5.0 application results in exception code 0xe0434352 #4485 ... seem to have issues with running a WPF app with PublishTrimmed=true.
Read more >How do I fix a .NET windows application crashing at startup ...
When running a command line application it would immediately exit, and I saw this exception in the Event Viewer but received no other...
Read more >WPF .NET application breaks with error Could not load file ...
I have a C# WPF .NET application that uses a 3rd party SDK called PaymentSDK.dll which I include and reference inside the application...
Read more >ArcGIS Runtime WPF application crashes when kept i...
Hi All, We have a WPF windows application developed using ArcGIS Runtime. ... NET Framework 4.6.1-WPF ... Exception code: 0xe0434352.
Read more >Creating and Publishing WPF and WinForm Apps in .NET Core
NET Framework WPF application for comparison to see what has changed. ... Source Code Download: https://leadmagnets. app /?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Trimming is not supported by WPF. There is now an error during compilation in .NET 6.0 when Trimming is enabled for WPF.
It was an intentional breaking change in the WindowsDesktop Sdk (WPF and WinForms). Starting with .Net 5 the Sdk will override the OutputType for WinExe. Which means that even if you set OutputType to Exe, it’ll end up being WinExe. You can override OutputType using the DisableWinExeOutputInference property: