maui icon indicating copy to clipboard operation
maui copied to clipboard

MAUI apps crash on launch on Windows after Visual Studio update - code 2147942405 (0x80070005)

Open holecekp opened this issue 2 years ago • 39 comments

Description

All apps stopped working on Windows after updating Visual Studio to the version 17.4.3 (which probably also updated MAUI). When I press F5, any app will not run and the following error message is displayed in the Output windows:

The program '[8104] MauiBugCrashOnLaunchOnWindows.exe' has exited with code 2147942405 (0x80070005).

The usual steps such as deleting bin and obj folders do not help. This affects all projects. Even an empty project created by Visual Studio template does not run.

Everything worked well with the previous version of VS/MAUI (I think it was MAUI 7.0.49 and VS 17.4.2).

Steps to Reproduce

  1. Create a File > New .NET MAUI App
  2. Run it on Windows (F5)
  3. The app will not run and error message is displayed in the Output window

... I can see that the issue cannot be saved without a link to a repro project. Because any project can be used to reproduce the issue I have added a link to a repro project for another issue to save time. This bug can be reproduced on it but as I have said before, it crashes even on an blank new project.

Link to public reproduction project repository

https://github.com/holecekp/MauiBugToolbar

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 21H2

Did you find any workaround?

No response

Relevant log output

'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: DefaultDomain): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\MauiBugCrashOnLaunchOnWindows.dll'. Symbols loaded.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.InteropServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\WinRT.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Collections.Concurrent.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Collections.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Runtime.CompilerServices.Unsafe.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Private.Uri.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.ObjectModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.ComponentModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MauiBugCrashOnLaunchOnWindows.exe' (CoreCLR: clrhost): Loaded 'D:\dotNET\MauiBugCrashOnLaunchOnWindows\MauiBugCrashOnLaunchOnWindows\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\AppX\System.Numerics.Vectors.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[8104] MauiBugCrashOnLaunchOnWindows.exe' has exited with code 2147942405 (0x80070005).

holecekp avatar Dec 14 '22 05:12 holecekp

In debug mode, they start for me, but in release mode, I also get an error 2022-12-14 095414

MaksimAdamenko avatar Dec 14 '22 06:12 MaksimAdamenko

And I also noticed that the apk for android has become about 3MB more

MaksimAdamenko avatar Dec 14 '22 06:12 MaksimAdamenko

I can confirm this problem for MAUI Blazor Hybrid as well. Doesn't matter for me if its in Release or Debug mode.

Dayjay avatar Dec 14 '22 09:12 Dayjay

Could be one of these

https://github.com/microsoft/WindowsAppSDK/issues/3197

https://github.com/microsoft/WindowsAppSDK/issues/3228

https://github.com/microsoft/WindowsAppSDK/issues/3137

espenrl avatar Dec 14 '22 10:12 espenrl

Could be one of these microsoft/WindowsAppSDK#3228

Can confirm, running the app once as admin works.

Dayjay avatar Dec 14 '22 10:12 Dayjay

Windows 10 or Windows 11? In my Win11 22621 VM I don't have the issue.

MagicAndre1981 avatar Dec 14 '22 10:12 MagicAndre1981

Windows 10 Pro 22H2 Build 19045.2364

Dayjay avatar Dec 14 '22 10:12 Dayjay

Windows 10 Pro 22H2 Build 19045.2364

espenrl avatar Dec 14 '22 11:12 espenrl

I have the same problem. The app deployment worked normally in VS 17.4.2.

Windows 10 22H2 Build 19045.2364

dajbych avatar Dec 14 '22 12:12 dajbych

ok, so this looks like a Windows 10 Bug in combination with WinApp SDK 1.2.x which will be fixed in 2023

The fix in Windows 10 OS is anticipated to be serviced on 3rd Tuesday of Jan 2023 as an OnDemand update patch and on 2nd Tuesday of Feb 2023 in an Auto update security patch.

MagicAndre1981 avatar Dec 14 '22 12:12 MagicAndre1981

I cannot understand how this is passed. So, now no one can build Windows apps until 2023? The fix is to what: rollback VS version?

bcaceiro avatar Dec 14 '22 12:12 bcaceiro

Same Problem here too !

lucianparvu avatar Dec 14 '22 12:12 lucianparvu

Rollback VS version did not work for me, instead it led to a broken MAUI installation.

imedia-peter avatar Dec 14 '22 12:12 imedia-peter

What worked for me: Build your app in any mode. It will crash on startup as expected.

Now go to the windows start menu, right click the app you just build: More => Run as Admin.

The app will start and so will every other MAUI app from now on even when started within Visual Studio.

Dayjay avatar Dec 14 '22 13:12 Dayjay

Yes, that worked for me too. I was overlooking this solution because I am still in the process of developing the MAUI app in Visual Studio. Thanks!

imedia-peter avatar Dec 14 '22 13:12 imedia-peter

My solution was to manually install the Microsoft.WindowsAppRuntime.1.2 redist

jpreece6 avatar Dec 14 '22 14:12 jpreece6

Current workaround is to run the app once as admin. Or manually installing the Microsoft.WindowsAppRuntime 1.2 redist.

Fix is coming automatically on Win 10 in Feb 2023:

This is a known issue in the Windows 10 OS and not an issue with the WinAppSDK. The fix in Windows 10 OS is anticipated to be serviced on 3rd Tuesday of Jan 2023 as an OnDemand update patch and on 2nd Tuesday of Feb 2023 in an Auto update security patch.

mattleibow avatar Dec 14 '22 15:12 mattleibow

@jpreece6 did you install the runtime from here? https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads#windows-app-sdk-12

mattleibow avatar Dec 14 '22 18:12 mattleibow

Hi @holecekp. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost avatar Dec 14 '22 19:12 ghost

@jpreece6 did you install the runtime from here? https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads#windows-app-sdk-12

Yep, runtime version 1.2.1.2.221116.1

jpreece6 avatar Dec 14 '22 19:12 jpreece6

I had this issue too, and running the app once as an admin didn't fix it. In fact, I was unable to even run the app as admin.

I just installed Visual Studio Community 2022 today, running the latest version.

Edition: Windows 10 Home Version: 22H2 OS build: 19045.2251 Experience: Windows Feature Experience Pack 120.2212.4180.0 Processor: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz 2.21 GHz

luizparente avatar Dec 14 '22 20:12 luizparente

@luizparente are you sure it is the same issue? Running as admin should fix it. Can you check your event log (EventViewer) and see whatthe app crash error is?

mattleibow avatar Dec 15 '22 00:12 mattleibow

I have very similar OS version as luiz. MAUI apps had been working for me until I upgraded to Visual Studio v17.4.3. A vanilla MAUI app from project template does not run and debug output window has this

The program '[21360] MauiApp1.exe' has exited with code 2147942405 (0x80070005).

Running VS as admin does not resolve the issue. Is there a way to continue MAUI development without undoing this VS upgrade?

Correction run MAUI app as admin worked. I missed that you have to choose the app that got deployed and run that (instead of thru VS).

jnery avatar Dec 15 '22 01:12 jnery

@mattleibow positive.

Here is what I did:

  1. Installed VS2022 Community today (version info below);
  2. Created a brand new MAUI app;
  3. Tried running the app by pressing F5;
  4. Got an error, was asked to turn on Developer Mode on Windows;
  5. Turned on Developer Mode on Windows;
  6. Back to VS, pressed F5 again to run;
  7. The debugger runs, tries to start the app; and
  8. Fails. The UI is never shown. The builder logs the error below.

The program '[9276] SimpleMauiApp.exe' has exited with code 2147942405 (0x80070005).

Seems to be an issue with an unregistered class in InteropServices... Or something along those lines.

When I try to run the generated .exe as admin, the Event Viewer logs an error with source on .NET Runtime:

Application: SimpleMauiApp.exe
CoreCLR Version: 7.0.122.56804
.NET Version: 7.0.1
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException: The type initializer for '<Module>' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'WinRT.ActivationFactory'1' threw an exception.
 ---> System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
   at WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName)
   at WinRT.ActivationFactory'1..ctor()
   at WinRT.ActivationFactory'1..cctor()
   --- End of inner exception stack trace ---
   at WinRT.ActivationFactory'1.ActivateInstance[I]()
   at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions..ctor()
   at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.get_Options() in C:\Users\luizp\.nuget\packages\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 44
   at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.AccessWindowsAppSDK() in C:\Users\luizp\.nuget\packages\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 30
   at .cctor()
   --- End of inner exception stack trace ---

It also logs another error with source "Application Error":

Faulting application name: SimpleMauiApp.exe, version: 1.0.0.0, time stamp: 0x6377b62e
Faulting module name: KERNELBASE.dll, version: 10.0.19041.2251, time stamp: 0x0d929ca0
Exception code: 0xe0434352
Fault offset: 0x0012e062
Faulting process id: 0x4640
Faulting application start time: 0x01d9102f6683654d
Faulting application path: D:\Path\To\SimpleMauiApp\SimpleMauiApp\bin\Release\net7.0-windows10.0.19041.0\win10-x86\SimpleMauiApp.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report Id: a40cdbbd-98f8-4c08-8ef0-c5849c156506
Faulting package full name: 
Faulting package-relative application ID: 

And an Event Viewer Information entry:

Fault bucket 1917344860151851230, type 1
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: SimpleMauiApp.exe
P2: 1.0.0.0
P3: 6377b62e
P4: KERNELBASE.dll
P5: 10.0.19041.2251
P6: 0d929ca0
P7: e0434352
P8: 0012e062
P9: 
P10: 

Attached files:
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER26E5.tmp.dmp
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2754.tmp.WERInternalMetadata.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER2764.tmp.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER276A.tmp.csv
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER277B.tmp.txt

These files may be available here:
\\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_SimpleMauiApp.ex_e4bcef75ea05e55a5ed54d2bba619b01981a84c_107c69d7_95c1858b-9e39-4dd8-b43b-fa92bc4fee7a

Analysis symbol: 
Rechecking for solution: 0
Report Id: a40cdbbd-98f8-4c08-8ef0-c5849c156506
Report Status: 268435456
Hashed bucket: 96fc34bc2ed296267a9bc6fde545a8de
Cab Guid: 0 

Below my VS instance info:

Microsoft Visual Studio Community 2022 Version 17.4.3 VisualStudio.17.Release/17.4.3+33205.214 Microsoft .NET Framework Version 4.8.04084 Installed Version: Community

luizparente avatar Dec 15 '22 03:12 luizparente

Running the app as admin first solved the problem for me (Windows 10, 21H2).

holecekp avatar Dec 15 '22 05:12 holecekp

Any one have solution for this BIG HEADAGE? I've the same trouble like this. And I've check that the new version can starting app OK if you are using .NET6 and It's fails if .NET7.

xuanait avatar Dec 15 '22 09:12 xuanait

Update: I recreated the app targeting.NET 6, and it works just fine. Can even run via VS.

luizparente avatar Dec 15 '22 16:12 luizparente

Same Problem here too!

jtinguely avatar Dec 15 '22 20:12 jtinguely

I ran Visual Studio as admin, then installed the redistributable from here, and my Windows 10 installation {with .NET 7 target) is now working. @jpreece6 https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads#windows-app-sdk-12

mike3sullivan avatar Dec 15 '22 21:12 mike3sullivan

Thank you so much, that worked!


From: mike3sullivan @.> Sent: Thursday, December 15, 2022 9:09 PM To: dotnet/maui @.> Cc: Joe Tinguely @.>; Comment @.> Subject: Re: [dotnet/maui] MAUI apps crash on launch on Windows after Visual Studio update - code 2147942405 (0x80070005) (Issue #12080)

I ran Visual Studio as admin, then installed the redistributable from here, and my Windows 10 installation is now working. @jpreece6https://github.com/jpreece6 https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads#windows-app-sdk-12

— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/maui/issues/12080#issuecomment-1353710571, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC5LHS2HCOIJMOZD3UORP7DWNOCI5ANCNFSM6AAAAAAS6BBRYM. You are receiving this because you commented.Message ID: @.***>

jtinguely avatar Dec 15 '22 22:12 jtinguely