microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.35k stars 677 forks source link

WINUI 3 Unable to Run Published App Due To KERNELBASE.dll Crash #6757

Open robinwilson16 opened 2 years ago

robinwilson16 commented 2 years ago

Describe the bug

I cannot get any WINUI desktop apps I create to run outside of Visual Studio however I publish them (single app or lots of files and with or without ClickOnce installation. I am using the 17.1 version of Visual Studio 2022 on the latest Windows 11 insider build.

Steps to reproduce the bug

Create a new Blank App, Packaged (WINUI 3 in Desktop) and then publish this (for example selecting ClickOnce then the single file option or deploying all files to a share). Nothing happens when the .exe is launched and looking in Event Viewer Application log the following errors appears:

First this one:

Application: App1.exe
CoreCLR Version: 6.0.222.6406
.NET Version: 6.0.2
Description: The process was terminated due to an unhandled exception.
Exception Info: System.DllNotFoundException: Dll was not found.
   at App1.Program.Main(String[] args)

Then this one:

Faulting application name: App1.exe, version: 1.0.0.0, time stamp: 0x61e1d094
Faulting module name: KERNELBASE.dll, version: 10.0.22557.1, time stamp: 0xab780977
Exception code: 0xe0434352
Fault offset: 0x00145df2
Faulting process ID: 0x0x5B90
Faulting application start time: 0x0x1D82778001B2502
Faulting application path: C:\Users\robin.wilson\AppData\Local\Apps\2.0\6WEQ0LKJ.QKZ\CM4PW9HN.PCX\app1..tion_0000000000000000_0001.0000_8e4f39cd130acc58\App1.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report ID: 253e7f9c-9d74-492f-9f03-89af28e232fc
Faulting package full name: 
Faulting package-relative application ID: 

Expected behavior

The app should launch and display the main window

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.0

Windows app type

Device form factor

No response

Windows version

No response

Additional context

No response

StephenLPeters commented 2 years ago

@evelynwu-msft FYI

BSchafer01 commented 2 years ago

Is there any feedback or guidance on this issue? I'm running into the same issue with the MSIX produced for sideloading a winUI 3 application.

mqudsi commented 2 years ago

You probably don't have it set to self-contained.

robinwilson16 commented 2 years ago

Still happens whatever options are picked and just doesn't work

victariox commented 2 years ago

I have the same problem and real problem is shadowed with Kernelbase.dll problem, any suggestions how to proceed with this ?

iR3turnZ commented 2 years ago

I also have the nearly the same problem but if i publish it into a folder it works. If I copy the files from the folder publish to the ClickOnce files i dont get a error that says that "Microsoft.WindowsAppRuntime.Bootstrap.dll" is missing anymore but I get the same KERNELBASE.dll error. Running WindowsAppSdk 1.1.2, VS 17.2.3 and Windows 19044.1766

applefanbois commented 1 year ago

I have the same problem, when I drag and drop a file on a dropActionHandler it will crash 1 in 10 times.

The dumbest thing ever is that I get a unhandled exception inside a try catch block.

Of course this is typical MS quality here.

c3rebro commented 1 year ago

I maybe have a similar issue in my WINUI3 Win32 (win10 x64 19045) Desktop App under .NET6.

The Application Runs fine when launched in Debug Mode. As a release build or when packed to folder (single file) i got these problems:

Published to Folder as single File: KERNELBASE.DLL Error like mentioned above Release Build: The App opens, but the Titlebar is "inactive". That means: no response to Max/Min/Close Buttons. Even Not dragable.

The TitleBar-Issue seems to be related to the AppSDk Version:

WinUI 3 - Windows App SDK 1.2.230118.102 = titlebar working WinUI 3 - Windows App SDK 1.2.230313.1 = titlebar not working

To reproduce the issue i had to clean the project (remove obj and bin folders in windows fileexplorer)

Downgrading to 1.2.230118.102 fixed the titlebar issue. However, i still get the kernelbase error when packed to a single file.

JoeTomkinson commented 1 year ago

I have this same exception; I have managed to isolate it to when I submit a message within the UI which in the background saves data to a file at the directory returned from:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Exception thrown at 0x00007FFA1681FE7C (KernelBase.dll) in appnamespace.exe: 0xE0434352 (parameters: 0xFFFFFFFF80070005, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00007FF8E1C60000).
onecore\com\combase\registrationstore\registrationstoredata.cpp(1055)\combase.dll!00007FFA175588B9: (caller: 00007FFA1754E1E5) ReturnHr(436) tid(2c80c) 80070002 The system cannot find the file specified.
onecore\com\combase\registrationstore\registrationstoredata.cpp(1055)\combase.dll!00007FFA175588B9: (caller: 00007FFA1754E1E5) ReturnHr(437) tid(2c80c) 80070002 The system cannot find the file specified.
Exception thrown at 0x00007FFA1681FE7C (KernelBase.dll) in appnamespace.exe: 0xE0434352 (parameters: 0xFFFFFFFF80070005, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00007FF8E1C60000).
Exception thrown at 0x00007FFA1681FE7C (KernelBase.dll) in appnamespace.exe: WinRT originate error - 0x80070005 : 'Access to the path 'C:\Program Files\WindowsApps\PUBLISHERINFO.329567E69597C_1.0.11.0_x64__1wwrtwbj9qrjm\bpe' is denied.'.
onecore\com\combase\winrt\error\restrictederror.cpp(1017)\combase.dll!00007FFA174EC07A: (caller: 00007FFA174F15EF) ReturnHr(438) tid(2c80c) 8007007E The specified module could not be found.
onecore\com\combase\winrt\error\restrictederror.cpp(1017)\combase.dll!00007FFA174EC07A: (caller: 00007FFA1768CF82) ReturnHr(439) tid(2c80c) 8007007E The specified module could not be found.
onecore\com\combase\winrt\error\restrictederror.cpp(1017)\combase.dll!00007FFA174EC07A: (caller: 00007FFA1768C95E) ReturnHr(440) tid(2c80c) 8007007E The specified module could not be found.
Unhandled exception at 0x00007FF9C9DED8BC (Microsoft.ui.xaml.dll) in appnamespace.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x0000023B74998140, 0x0000000000000003).

Warning: Unable to load Dynamic Function Table Callback DLL 'C:\Program Files\WindowsApps\PUBLISHERINFO.329567E69597C_1.0.11.0_x64__1wwrtwbj9qrjm\mscordaccore.dll'. Call stacks may be truncated. Access is denied.

The Exception Message is:

Unhandled exception at 0x00007FF9C9DED8BC (Microsoft.ui.xaml.dll) in appnamespace.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x0000023B74998140, 0x0000000000000003).

I thought maybe it was an elevation issue, but that doesn't seem to be the case. This works in Debug and Release for x32 and x64. Not sure if anyone has any suggestions as to where to look.

benaclejames commented 1 year ago

+1 to this, even seems to happen on a fresh VM. Very strange

JoeTomkinson commented 1 year ago

I have this same exception; I have managed to isolate it to when I submit a message within the UI which in the background saves data to a file at the directory returned from:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Exception thrown at 0x00007FFA1681FE7C (KernelBase.dll) in appnamespace.exe: 0xE0434352 (parameters: 0xFFFFFFFF80070005, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00007FF8E1C60000).
onecore\com\combase\registrationstore\registrationstoredata.cpp(1055)\combase.dll!00007FFA175588B9: (caller: 00007FFA1754E1E5) ReturnHr(436) tid(2c80c) 80070002 The system cannot find the file specified.
onecore\com\combase\registrationstore\registrationstoredata.cpp(1055)\combase.dll!00007FFA175588B9: (caller: 00007FFA1754E1E5) ReturnHr(437) tid(2c80c) 80070002 The system cannot find the file specified.
Exception thrown at 0x00007FFA1681FE7C (KernelBase.dll) in appnamespace.exe: 0xE0434352 (parameters: 0xFFFFFFFF80070005, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x00007FF8E1C60000).
Exception thrown at 0x00007FFA1681FE7C (KernelBase.dll) in appnamespace.exe: WinRT originate error - 0x80070005 : 'Access to the path 'C:\Program Files\WindowsApps\PUBLISHERINFO.329567E69597C_1.0.11.0_x64__1wwrtwbj9qrjm\bpe' is denied.'.
onecore\com\combase\winrt\error\restrictederror.cpp(1017)\combase.dll!00007FFA174EC07A: (caller: 00007FFA174F15EF) ReturnHr(438) tid(2c80c) 8007007E The specified module could not be found.
onecore\com\combase\winrt\error\restrictederror.cpp(1017)\combase.dll!00007FFA174EC07A: (caller: 00007FFA1768CF82) ReturnHr(439) tid(2c80c) 8007007E The specified module could not be found.
onecore\com\combase\winrt\error\restrictederror.cpp(1017)\combase.dll!00007FFA174EC07A: (caller: 00007FFA1768C95E) ReturnHr(440) tid(2c80c) 8007007E The specified module could not be found.
Unhandled exception at 0x00007FF9C9DED8BC (Microsoft.ui.xaml.dll) in appnamespace.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x0000023B74998140, 0x0000000000000003).

Warning: Unable to load Dynamic Function Table Callback DLL 'C:\Program Files\WindowsApps\PUBLISHERINFO.329567E69597C_1.0.11.0_x64__1wwrtwbj9qrjm\mscordaccore.dll'. Call stacks may be truncated. Access is denied.

The Exception Message is:

Unhandled exception at 0x00007FF9C9DED8BC (Microsoft.ui.xaml.dll) in appnamespace.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x0000023B74998140, 0x0000000000000003).

I thought maybe it was an elevation issue, but that doesn't seem to be the case. This works in Debug and Release for x32 and x64. Not sure if anyone has any suggestions as to where to look.

I narrowed my issue down to a 3rd party NuGet package with a literal directory path trying to write data to somewhere it wasn't allowed to once it was installed within the WindowsApps directory once it's installed from the store or sideloaded.

You'd think there would be a more meaningful exception being raised natively for this.

hugocvx commented 1 year ago

Same for me on two fresh install today. Sample app run in debug with visual, but not outside of visual or with publishing process.

robinwilson16 commented 1 year ago

I had to switch to WFP to get my app to work last time and re-do parts of it. Before I start my next app and find it won't publish either, has this issue/bug been fixed and will WINUI apps publish without crashing as I notice a year and a half later it is still open and others reporting the same issue and no fix or workaround as far as I can tell.

applefanbois commented 1 year ago

Stay away from this stinker.

IsmailHassani commented 7 months ago

Maybe a little bit late, but i noticed that this issue is still open. So here it goes.

Check if you're code make use a foreach loop. If the foreach loops through a null valued list, your application will crash. The strange thing is that most of the time the application just crashes as you mentioned. But in very rare case (1 out of the 25 times) it manages to stick to the debugger and show the actual error.

So instead of using:

foreach (var item in list)
{
}

which potential could be null, use an extension method

foreach (var item in list.EnsureNotNull())
{
}

The extension method can be simple as source

    /// <summary>
    /// Ensures enumerable is not null
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="list">The list.</param>
    /// <returns>IEnumerable&lt;T&gt;.</returns>
    public static IEnumerable<T> EnsureNotNull<T>(this IEnumerable<T> list)
    {
        return list ?? Enumerable.Empty<T>();
    }