dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.

Home Page:https://dot.net/maui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

holecekp opened this issue · comments

UPDATE: Jan 20, 2023 (Link to Comment)

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?

#12080 (comment)
OR #12080 (comment)
OR #12080 (comment)

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).

VS bug #1745792

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

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

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

Could be one of these
microsoft/WindowsAppSDK#3228

Can confirm, running the app once as admin works.

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

Windows 10 Pro 22H2
Build 19045.2364

Windows 10 Pro 22H2
Build 19045.2364

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

Windows 10 22H2
Build 19045.2364

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.

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?

Same Problem here too !

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

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.

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!

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

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.

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.

@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

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 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?

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).

@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

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

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.

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

Same Problem here too!

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

commented

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

Thanks now its ok

I tried rolling back to 17.4.2 and that did not fix it. Apps which worked fine under 17.4.2 (before the upgrade to 17.4.3) still do not work. 👎

And this is what happens if a company does not test their products x) Not a suprise because the quality is utterly bad since at least 3 years for every Microsoft developer product.

commented

Downloading https://aka.ms/windowsappsdk/1.2/1.2.221209.1/Microsoft.WindowsAppRuntime.Redist.1.2.zip and running its WindowsAppRuntimeInstall.exe (as admin) has solved the issue for me.

Downloading https://aka.ms/windowsappsdk/1.2/1.2.221209.1/Microsoft.WindowsAppRuntime.Redist.1.2.zip and running its WindowsAppRuntimeInstall.exe (as admin) has solved the issue for me.

Fix the problem on Windows for me. WHy am i needing this ?

Downloading https://aka.ms/windowsappsdk/1.2/1.2.221209.1/Microsoft.WindowsAppRuntime.Redist.1.2.zip and running its WindowsAppRuntimeInstall.exe (as admin) has solved the issue for me.

Fix the problem on Windows for me. WHy am i needing this ?

They are fixing it (see above). But if you want it to work in the meantime, you need to install the above as a workaround or right-click and run as admin, which is working for some people.

commented

Having the same issue here. For me, installing the Windows App SDK 1.2 redistributable fixed it (as others in this thread have also mentioned):

https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads#windows-app-sdk-12

This seems like a huge bug for Microsoft to let through the door.

Having the same issue here. For me, installing the Windows App SDK 1.2 redistributable fixed it (as others in this thread have also mentioned):

https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads#windows-app-sdk-12

This seems like a huge bug for Microsoft to let through the door.

And seems like a pretty simple test case: Does the template run on Windows 10? 🤷

commented

these steps are still working for myself : build, let it immediately exit, close VS, download & run installer for Windows App SDK 1.2.2 (1.2.221209.1). Then, run the app that was built earlier from the start menu as admin. when next opening VS it'll build and stay open as you'd expect

This seems like a huge bug for Microsoft to let through the door.

And seems like a pretty simple test case: Does the template run on Windows 10? 🤷

yeah and its amazing , its so funny to me that this got out . legends

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

That works for me, downloaded from here https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads

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

It works for the Hello World project, but not for mine. My project throws
'System.TypeInitializationException' in Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll.

A further dig into the exception shows Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions is not registered (hr=0x80040154)

 	System.Private.CoreLib.dll!System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(int errorCode) Line 882	C#
>	Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll!WinRT.BaseActivationFactory.BaseActivationFactory(string typeNamespace, string typeFullName) Line 52	C#
 	Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll!WinRT.ActivationFactory<Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions>.ActivationFactory() Line 13	C#
 	Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll!WinRT.ActivationFactory<Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions>.ActivationFactory()	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll!WinRT.ActivationFactory<Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions>.ActivateInstance<WinRT.Interop.IUnknownVftbl>() Line 34	C#
 	Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll!Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentInitializeOptions.DeploymentInitializeOptions() Line 91	C#
 	CreateTable2CodeMAUI.dll!Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.Options.get() Line 44	C#
 	CreateTable2CodeMAUI.dll!Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.AccessWindowsAppSDK() Line 30	C#
 	CreateTable2CodeMAUI.dll!<Module>.<Module>()	Unknown

Same problem here, and it seems fixed now after I tried suggestions provided by you guys.
I have a Windows 11 and Windows 10 machine, and both have installed the exact same version of Visual Studio 2022: 17.5.0 Preview 2.0.

On Windows 11, my MAUI project works (targeting .NET 7). The application can deploy and run just fine.
However, on Windows 10 22H2 build 19045.2364, the project cannot run in Visual Studio 2022, nor can it run with a command console that is Run as Administrator.

I found the following application error in Windows 10 Event Log:

Application: MyMauiApp.exe
CoreCLR Version: 7.0.22.51805
.NET Version: 7.0.0
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): 類別未登錄 (0x80040154 (REGDB_E_CLASSNOTREG))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   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\Huanlin\.nuget\packages\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 44
   at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.AccessWindowsAppSDK() in C:\Users\Huanlin\.nuget\packages\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 30
   at .cctor()
   --- End of inner exception stack trace ---

Then I install Windows App SDK 1.2.2, restart Windows 10. It works now. However, it seems not stable on Windows 10 because sometimes Visual Studio 2022 is not responding after I open my MAUI project and hit F5 or Ctrl+F5.

I'm having the same issue, where I can't run a brand new Maui app. I also can't delete my project folder even after closing VS. I had to restart my computer to delete it. What am I looking for in Task Manager to force close this?

I tried installing this: https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads#windows-app-sdk-12

Still doesn't run, I get no errors.

A basic smoke test would have caught this.

Create project, start it...

commented

these steps are still working for myself : build, let it immediately exit, close VS, download & run installer for Windows App SDK 1.2.2 (1.2.221209.1). Then, run the app that was built earlier from the start menu as admin. when next opening VS it'll build and stay open as you'd expect

This seems like a huge bug for Microsoft to let through the door.

And seems like a pretty simple test case: Does the template run on Windows 10? 🤷

yeah and its amazing , its so funny to me that this got out . legends

That's because the XF/Maui team is historically very! bad with quality control. This is nothing new.
Builds notoriously breaking with every second VS updates has been the standard on VS4Mac and Xamarin.
Not to mention the the overwhelming amount of incomplete or buggy features in xamarin.forms.

From this page :
https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads
Installing Windows App SDK 1.2.2 (x64) then 1.2 (x64) after that, worked like a charm.

Running Windows 10 22H2, Visual studio Community 2022 17.4.3 (latest).

I'm having the same issue, where I can't run a brand new Maui app. I also can't delete my project folder even after closing VS. I had to restart my computer to delete it. What am I looking for in Task Manager to force close this?

Update: switching the framework to .net 6 works, so this isn't a showstopper, but it seems like an odd bug to have gotten by the QA folks. Yell if you want help with testing this, please.

(apologies for the formatting. For the life of me, I can't get md to format anything as code)

I'm having the same problem as everyone above in terms of the default Maui example app crashing on run on Windows. This happens regardless of what's running as 'administrator' or no, reinstalling SDKs, etc.

As for being unable to delete directory trees, if you're building/running for Android, it's possible that adb.exe is holding open a directory. How did I find this out? The amazing LockSmith tool in Microsoft PowerToys.

**Environment

  • Microsoft Windows 10 Pro - v10.0.19045 Build 19045
  • Visual Studio Enterprise 2022 (64-bit) Version 17.4.3
  • Microsoft .NET SDK 7.0.101 (x64) from Visual Studio

from Event Viewer

Application Error

Faulting application name: MoodBoard.exe, version: 1.0.0.0, time stamp: 0x6377ba57
Faulting module name: KERNELBASE.dll, version: 10.0.19041.2364, time stamp: 0x5b7d4d22
Exception code: 0xe0434352
Fault offset: 0x000000000002cd29
Faulting process id: 0x4c50
Faulting application start time: 0x01d91c8c820fdf5a
Faulting application path: D:\src\MoodBoard\MoodBoard\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\MoodBoard.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 5272d252-d877-4de9-9ad0-6bafbc1f56e2
Faulting package full name:
Faulting package-relative application ID:

.NET Runtime

Application: MoodBoard.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 System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   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\lynne.whitehorn\.nuget\packages\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 44
   at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.AccessWindowsAppSDK() in C:\Users\lynne.whitehorn\.nuget\packages\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 30
   at .cctor()
   --- End of inner exception stack trace ---

I found this still works if you create a project in .net 6, but for .net 7 does not work at all in VS 7.4.3

I had the same error and I even tried repairing Visual Studio
The program '[8104] MauiBugCrashOnLaunchOnWindows.exe' has exited with code 2147942405 (0x80070005).e error
Edition Windows 10 Pro
Version 21H2
Installed on ‎1/‎8/‎2022
OS build 19044.2075
Experience Windows Feature Experience Pack 120.2212.4180.0
Apparently running the crashing app as admin solved the problem.

Here's what I'm facing. The project launches fine on a different machine but it's not my primary dev box.
Screenshot 2023-01-03 182621
Screenshot 2023-01-03 182808

Same with me, running the app as admin helped (VS Preview 2 / .NET 7)

Worked for me for a dummy test .net 7 app and for my app but just installing the new runtime SDK 1.2.
But my actual app has lost some of its colours, have to look into it. Maybe there is a bug there?

Running as admin made it far worse.

In my case the app builds/runs fine, but running "add-migration" in package manager produces the same error above.

Installing 1.2.2 and 1.2 as admin did not help,
Running VS 2022 normally/as admin did not help,
Restarting the machine did not help.

Using Windows 11

Using Windows 11

the original 22000.x or 2262x? I use the 22621.x and here I don't have this. this should Win10 only.

Using Windows 11

the original 22000.x or 2262x? I use the 22621.x and here I don't have this. this should Win10 only.

Says it has the latest updates; it's odd how the app builds fine when running the build command, but fails spectacularly when running a migration!

Using Windows 11

the original 22000.x or 2262x? I use the 22621.x and here I don't have this. this should Win10 only.

Says it has the latest updates; it's odd how the app builds fine when running the build command, but fails spectacularly when running a migration!

Can you paste the error here?

Says it has the latest updates;

run winver.exe and look at the version

I'm having the exact same problem with a project completed on 12/10/2022. Since I've updated VS 2022 to 17.4.3.
I'm running Windows 10 Version 22H2 (OS Build 19045.2364). I've also installed SDK 1.2.2, run as admin, run VS as admin.

Still getting the same error The program '[84668] APRemittanceEmail.exe' has exited with code 2147942405 (0x80070005).

Events:

Error .NET Runtime Event ID 26
Application: APRemittanceEmail.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 System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   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\jclark\.nuget\packages\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 44
   at Microsoft.Windows.ApplicationModel.WindowsAppRuntime.DeploymentManagerCS.AutoInitialize.AccessWindowsAppSDK() in C:\Users\jclark\.nuget\packages\microsoft.windowsappsdk\1.2.221109.1\include\DeploymentManagerAutoInitializer.cs:line 30
   at .cctor()
   --- End of inner exception stack trace ---

and Event Application Error Event ID 1000

Faulting application name: APRemittanceEmail.exe, version: 1.0.0.0, time stamp: 0x6377ba57
Faulting module name: KERNELBASE.dll, version: 10.0.19041.2364, time stamp: 0x5b7d4d22
Exception code: 0xe0434352
Fault offset: 0x000000000002cd29
Faulting process id: 0xdb90
Faulting application start time: 0x01d924463e355aae
Faulting application path: C:\Users\jclark\source\Workspaces\Degen Financial Utilities\Financial\APRemittanceEmail\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\APRemittanceEmail.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: bbe8faad-91e6-4a0e-8bbb-bc6f9fc320b0
Faulting package full name: 
Faulting package-relative application ID: 

I got the exact same error here.
This can be easily reproducible by creating a brand new MAUI app with the freshly installed Visual Studio Community 2022 (64-bit) Version 17.4.3 on Windows 10 machine. (Don't need to change the project source at all. )

Installing the Windows App SDK 1.2 redistributable has fixed it as many people mentioned here.

Thanks to everyone in this thread to save me from the nightmare.

A workround seems to be to set

<WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize>

in my csproj. This is because the wasdk is adding some extra dependency by accident. So this disables that.

3 separate testers of our app affected by this issue have confirmed your workaround fixes the issue - thanks @mattleibow!

commented

<WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize> worked for me @mattleibow . Thank you

Same here. Really appreciate it @mattleibow!

I don't understand.
VS does not show the csproj file. I tried to open it with N++ but there is no line WindowsAppSdkDeploymentManagerInitialize

I tried to open it with N++ but there is no line WindowsAppSdkDeploymentManagerInitialize

you need to add this on your own

A workround seems to be to set

<WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize>

in my csproj. This is because the wasdk is adding some extra dependency by accident. So this disables that.

Just verified that the issue is still present as of 1/17/23 and this fixed the issue.

Using Windows 11

the original 22000.x or 2262x? I use the 22621.x and here I don't have this. this should Win10 only.

Says it has the latest updates; it's odd how the app builds fine when running the build command, but fails spectacularly when running a migration!

Can you paste the error here?

Apologies for not replying earlier!
The error stack trace is exactly the same as the one shown above

I got my migrations working by creating a separate .net7 library containing models and dbcontext (moved from main project), and a .net7 console app to run migrations (so i don't have to deal with the weird target frameworks in the main project).

I didn't try the other solution from @mattleibow so can't confirm if it would've helped in my case.

A workround seems to be to set

<WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize>

in my csproj. This is because the wasdk is adding some extra dependency by accident. So this disables that.

Anyways, if someone is struggling with this error during migrations specifically, I hope this approach can help.

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.

Esto funciono para mi, muchas gracias

Looking at winui docs I see this: https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/deployment-architecture#key-terms

We lose these features when we disable the deployment manager:

  • Main package
    Package that contains background tasks to keep track of dynamic dependencies, and enables automatic updates to the Framework package from the Microsoft Store.
  • Singleton package
    Contains background tasks, services, app extensions, and other components not included in the Framework package such as Push Notifications. This is generally a single long-running process that is brokered between apps.

We have merged what we think is a good fix.

We have merged what we think is a good fix.

When will this fix be available? Does MAUI 7.0.58 (SR2) include it?

When will this fix be available? Does MAUI 7.0.58 (SR2) include it?

@mattleibow
Could the MAUI team add milestone to issues which are fixed? We don't know when to expect this change.
For example this issue as well: "merged"/"fixed" but it is not available for developers using MAUI.
#10858 (comment)

There is now a January Preview Update for Windows 10:

January 19, 2023—KB5019275 (OS Builds 19042.2546, 19044.2546, and 19045.2546) Preview
https://support.microsoft.com/en-us/topic/january-19-2023-kb5019275-os-builds-19042-2546-19044-2546-and-19045-2546-preview-8ae1b678-d38c-4249-848d-06b722e7c0ad

Support page doesn't mention the fix, so maybe some Win10 users who still have the issue can try the update?

@MagicAndre1981

I tried to open it with N++ but there is no line WindowsAppSdkDeploymentManagerInitialize

you need to add this on your own

I tried adding the following.
<WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize>
in various places in the csproj file but it stopped loading the project, even after removing the line.
It now tells me that depending on the solution, additional components may need to be installed to take advantage of the full development experience. Error not giving me before editing csproj. Also now the project appears to be downloaded from the internet.

I tried adding the following. false in various places in the csproj file but it stopped loading the project

remove the entry and try to install the Windows 10 update.

I'll try it now. Where in the file should I paste that line? Or is it just a case of not updating Windows?

MAUI 7.0.58 does not yet include this fix, however the upcoming 7.0.59 release will include it.

We've made a couple of changes to mitigate the Windows OS bug:

  1. We are setting <PropertyGroup><WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize></PropertyGroup> to disable the automatic code generation of the Deployment Manager by the Windows App SDK.
  2. We are calling the Deployment Manager Initialize code ourselves and handling the result differently than the generated invocation from the Windows App SDK.

Ultimately the Windows OS level bug was causing the Deployment Manager's Initialize call to return a failed result (due to an Access Denied error, which is why running the app as Admin would fix this). The generated code from the Windows App SDK would abrubtly invoke Environment.Exit on a failed result and did not log any useful information when this happened. Previous versions of WindowsAppSDK (1.1.x) had a different order of evaluating MSBuild properties and did not automatically include the generated code to call this initialize method which is why we didn't see the bug in MAUI before this.

Since we are calling this Deployment Manager Initialize method ourselves now within MAUI instead, we are choosing to not exit immediately on a failed result, since in many cases the app will still work as expected. This call is mostly important for apps using windows specific notification API's and a few others, which many MAUI apps will not be using as it installs the additional framework references that ship with the windows app runtime but can't be installed in all distribution scenarios. It's correct to have this call in a MAUI app regardless of if you think you need it, the bug isn't in the fact that the deployment manager is being called, but rather in that on Windows 10 there was a bug where that call required elevation.

The reason this change works around the Windows 10 OS bug is that we are choosing to not fail if the deployment manager cannot complete because it's possible the app will still execute normally, which is the same behaviour MAUI apps had in previous releases.

To summarize, there are a few ways this issue can be mitigated:

  1. Update to the latest Windows 10 OS January 19 update
  2. Manually install the runtime with the Windows App SDK Runtime Installer
  3. Set the project property in your MAUI app project: <PropertyGroup><WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize></PropertyGroup>
  4. Update to MAUI 7.0.59 when it is released in the coming weeks

Of all suggested workarounds, these worked for me:

  1. <WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize> in csproj
  2. Manually installing latest WIndows App SDK runtime

And these did not work:

  1. Running app as admin
  2. Installi Windows Update KB5019275

I am using VS Community 17.4.3 with MAUI 7.0.52. Also as suggested for the future to update to MAUI 7.0.59 is it possible to just update MAUI version or we have to wait until a VS update is available with updated version of MAUI?

MAUI 7.0.59 is now released as part of 17.5 Preview 5 @danielkraut

Manually installing latest Windows App SDK runtime helped

Thanks. Just adding <WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize> to the project file solved the problem on my end.

We still cannot get an installable Release build from our Azure Pipeline to start normally on a Windows 10 machine, following all the workarounds from this issue:

  • Install latest Windows App SDK Runtime on target machine
  • Include <WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize> in csproj file
  • Run app as Administrator

dotnet workload install ... installs .Net SDK 7.0.102 on the build machine and we see the output Installing workload manifest microsoft.net.sdk.maui version 7.0.59… in the build logs, meaning this is the version that should produce a flawless release build, if I read this issue correctly, right?

Nevertheless: Whenever we try to install & start the generated msix file, the app will not be started at all. Not even a window pops up and there is no error recorded in the Windows event viewer either.

We have to manually build for Release mode on a developer's machine in Visual Studio for now, but we really would like to produce our Release builds in a more streamlined fashion.
Does anyone have an idea if there is an obscure/special switch for the dotnet workloads install or dotnet publish commands that needs to be flipped for this to work?

install the updates from todays Patchday, it includes the optional update from end January 2023.

install the updates from todays Patchday, it includes the optional update from end January 2023.

Negative. We updated 2 Windows 10 target machines with the latest from Windows Update (including optionals) and the behaviour persists.

Admitted: Since this is the output from dotnet publish in release mode and the crashes leave no traces in the event logs or anywhere else, I'm not entirely sure this is the same bug as described by the original author.
It just sounds very similar and I'm at a loss for further debugging options.
It might as well be we stumbled on yet another, unrelated, crashing bug :/

install the updates from todays Patchday, it includes the optional update from end January 2023.

Negative. We updated 2 Windows 10 target machines with the latest from Windows Update (including optionals) and the behaviour persists.

VS 2022 17.4.5 also includes the MAUI 7.0 SR3 7.0.59:

Ask @Redth what else is needed to get this fixed.

VS 2022 17.4.5 also includes the MAUI 7.0 SR3 7.0.59:

Ask @Redth what else is needed to get this fixed.

Sorry, maybe I'm a bit slow on the uptake, but I don't see how updating my Visual Studio is gonna help me fix the problems with our Azure build, where (according to build logs) MAUI 7.0.59 is already being used.
In fact we have to manually ship release binaries from a developer's Visual Studio which apparently work better or at least start, compared to what dotnet publish outputs for Windows.

I suggest we leave it at that for now. We'll see how the next release of MAUI behaves in our Azure Pipeline and if that still produces unstartable binaries on Windows, I'll open another issue.
Sorry for stirring this up.

This problem still exists to this day :(

I have tried the following methods, not working:

  • Manually install the runtime with the Windows App SDK Runtime Installer
  • Set the project property in your MAUI app project: <PropertyGroup><WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize></PropertyGroup>

My development environment:

Microsoft Visual Studio Community 2022 Version 17.4.5
VisualStudio.17.Release/17.4.5+33403.182

Windows 11 Pro 22H2
OS Version 22621.1105
Windows Feature Experience Pack 1000.22638.1000.0


I can't understand why Microsoft's testers didn't find this problem.