Error publishing a single executable
See original GitHub issueDescribe the bug
When publishing an application with the “produce a single file” publishing setting enabled, the published application (.exe) doesn’t open. The event viewer shows the following error
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Application Error" Guid="{a0e9b465-b939-57d7-b27d-95d8e925ff57}" />
<EventID>1000</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>100</Task>
<Opcode>0</Opcode>
<Keywords>0x8000000000000000</Keywords>
<TimeCreated SystemTime="2022-12-27T17:18:37.9947560Z" />
<EventRecordID>4695</EventRecordID>
<Correlation />
<Execution ProcessID="25028" ThreadID="22632" />
<Channel>Application</Channel>
<Computer>DESKTOP-ED46SDN</Computer>
<Security UserID="S-1-5-21-1370086028-2928665489-3087911640-1003" />
</System>
<EventData>
<Data Name="AppName">UiDesktopApp1.exe</Data>
<Data Name="AppVersion">1.0.0.0</Data>
<Data Name="AppTimeStamp">6377dc84</Data>
<Data Name="ModuleName">KERNELBASE.dll</Data>
<Data Name="ModuleVersion">10.0.25267.1000</Data>
<Data Name="ModuleTimeStamp">7b673108</Data>
<Data Name="ExceptionCode">e0434352</Data>
<Data Name="FaultingOffset">000000000003b77c</Data>
<Data Name="ProcessId">0x3fd8</Data>
<Data Name="ProcessCreationTime">0x1d91a174175962f</Data>
<Data Name="AppPath">%USERPROFILE%\Downloads\pub\UiDesktopApp1.exe</Data>
<Data Name="ModulePath">C:\WINDOWS\System32\KERNELBASE.dll</Data>
<Data Name="IntegratorReportId">a4c17f60-a25d-4b78-857b-db5faf6119a0</Data>
<Data Name="PackageFullName" />
<Data Name="PackageRelativeAppId" />
</EventData>
</Event>
When publishing as a single file, I get several errors related to variables that do not accept NULL values
The field element "_navigationWindow" that doesn't accept NULL values must contain a value other than NULL when exiting the constructor. Consider declaring the field element as accepting a NULL value.
My assumption is, that being a single file, the system is not prepared to run as a single file, as it will always try to read the wpf.ui libraries externally (.dll).
To Reproduce
- Create or open your solution
- In the solution exporter, right click on the application and select publish.
- In the publish tab, configure the publication, you have to select any target runtime environment to any one that is not “portable” (In my case win-x64, although it also happens with x86. I do not know if it also happens with other systems like Linux).
- When selecting any that is not portable, extra options appear, you have to check the box to produce a single file and save.
- Publish and run
PS: My language is Spanish PS 2: %userprofile% is actually C:\Users\ [my user]
Expected behavior
Program to run (open normally)
Screenshots
No response
OS version
OS: Win 11 Ver. 0.0.25267 build 25267 (insider)
.NET version
Microsoft Visual Studio Community 2022 Versión 17.4.3 VisualStudio.17.Release/17.4.3+33205.214 Microsoft .NET Framework Versión 4.8.09032
Versión instalada: Community
Visual C++ 2022 00482-90000-00000-AA468
Adaptador de prueba para Boost.Test 1.0
ADL Tools Service Provider 1.0
Administrador de paquetes NuGet 6.4.0
ASA Service Provider 1.0
ASP.NET and Web Tools 17.4.326.54890ASP.NET and Web Tools
Azure Data Lake Tools for Visual Studio 2.6.5000.0
Azure Functions and Web Jobs Tools 17.4.326.54890
Azure Stream Analytics Tools for Visual Studio 2.6.5000.0
Cookiecutter 17.0.22263.6
Depuración de volcados de memoria básicos de Linux 1.0.9.33020
Dotfuscator Community Edition 6.5.0+76d4669002
Extensibility Message Bus 1.4.1 (main@2ee106a)
Extensión de VSPackage 1.0
Herramientas comunes de Windows Azure 1.10
Herramientas de Azure App Service v3.0.0 17.4.326.54890
Herramientas de C# 4.4.0-6.22580.4+d7a61210a88b584ca0827585ec6e871c6b1c5a14
Herramientas de Node.js 1.5.40817.1 Commit Hash:66443775f9f3b1d8f8fee47af5002828b346688d
Herramientas de TypeScript 17.0.10921.2001
Herramientas de Visual Basic 4.4.0-6.22580.4+d7a61210a88b584ca0827585ec6e871c6b1c5a14
Herramientas de Visual F# 17.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b
Microsoft Azure Hive Query Language Service 2.6.5000.0
Microsoft Azure Stream Analytics Language Service 2.6.5000.0
Microsoft JVM Debugger 1.0
Mono Debugging for Visual Studio 17.4.19 (8c0a575)
Python con Pylance 17.0.22263.6
Python: compatibilidad con proyectos de VC 17.0.21344.1
Python: compatibilidad de Django 17.0.22263.6
Python: compatibilidad de la generación de perfiles 17.0.22263.6
Razor (ASP.NET Core) 17.0.0.2246202+61cc048d36a3fc9246d2f04625988b19a18ab8f0
SQL Server Data Tools 17.0.62207.28050
Test Adapter para Google Test 1.0
ToolWindowHostedEditor 1.0
Visual C++ for Linux Development 1.0.9.33020
Visual Studio IntelliCode 2.2
Visual Studio Tools para Unity 17.4.3.0
VisualStudio.DeviceLog 1.0
VisualStudio.Mac 1.0
Xamarin 17.4.0.312 (d17-4@be7e8d1)
Xamarin Designer 17.4.0.138 (remotes/origin/d17-4@d36bba3cc9)
Xamarin Templates 17.4.2 (c457c97)
Xamarin.Android SDK 13.1.0.1 (d17-4/13ba222) Mono: a96bde9 Java.Interop: xamarin/java.interop/d17-4@fcc33ce2 SQLite: xamarin/sqlite/3.39.3@23e1ae7 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@0be567a
Xamarin.iOS and Xamarin.Mac SDK 16.1.1.27 (933c6c2c9)
WPF-UI NuGet version
2.0.3
Additional context
No response
Issue Analytics
- State:
- Created 9 months ago
- Comments:8 (5 by maintainers)
I fixed this issue by setting the setting the
BasePath
as follows:.ConfigureAppConfiguration(c => { c.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)); })
This code can be found in App.xaml.csAccording to Microsoft :
<html> <body>About other files, the gallery code is already changed in the
development
branch, and for the extensions, I think a deeper refactor should be done to adapt them to the new navigation system in version 3.0.0