maui: MAUI apps crash on launch on Windows after Visual Studio update - code 2147942405 (0x80070005)
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
- Create a File > New .NET MAUI App
- Run it on Windows (F5)
- 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?
https://github.com/dotnet/maui/issues/12080#issuecomment-1377243186 OR https://github.com/dotnet/maui/issues/12080#issuecomment-1351322492 OR https://github.com/dotnet/maui/issues/12080#issuecomment-1351671363
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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 40
- Comments: 89 (21 by maintainers)
Links to this issue
Commits related to this issue
- Disable WinUI optional extras by default Works around https://github.com/microsoft/WindowsAppSDK/issues/3316 Avoids https://github.com/dotnet/maui/issues/12080 — committed to dotnet/maui by mattleibow a year ago
- Disable WinUI optional extras by default (#12530) Works around https://github.com/microsoft/WindowsAppSDK/issues/3316 Avoids https://github.com/dotnet/maui/issues/12080 — committed to dotnet/maui by mattleibow a year ago
- Disable WinUI optional extras by default Works around https://github.com/microsoft/WindowsAppSDK/issues/3316 Avoids https://github.com/dotnet/maui/issues/12080 — committed to dotnet/maui by mattleibow a year ago
- Disable WinUI optional extras by default Works around https://github.com/microsoft/WindowsAppSDK/issues/3316 Avoids https://github.com/dotnet/maui/issues/12080 — committed to dotnet/maui by mattleibow a year ago
- Disable WinUI optional extras by default (#12552) Works around https://github.com/microsoft/WindowsAppSDK/issues/3316 Avoids https://github.com/dotnet/maui/issues/12080 Co-authored-by: Matthew Le... — committed to dotnet/maui by github-actions[bot] a year ago
- Disable WinUI optional extras by default (#12551) Works around https://github.com/microsoft/WindowsAppSDK/issues/3316 Avoids https://github.com/dotnet/maui/issues/12080 Co-authored-by: Matthew Le... — committed to dotnet/maui by github-actions[bot] a year ago
- apply potential fix for non-starting issue on win10 (https://github.com/dotnet/maui/issues/12080) — committed to dragonfruitnetwork/dragon6 by aspriddell a year ago
- Dev/ios guid splash (#12759) * [net7.0] Update dependencies from xamarin/xamarin-macios (#11220) * Update dependencies from https://github.com/xamarin/xamarin-macios build 20221108.30 Microsoft... — committed to dotnet/maui by mattleibow a year ago
- Disable WinUI optional extras by default (#12530) Works around https://github.com/microsoft/WindowsAppSDK/issues/3316 Avoids https://github.com/dotnet/maui/issues/12080 — committed to dotnet/maui by mattleibow a year ago
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.
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.
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?
My solution was to manually install the Microsoft.WindowsAppRuntime.1.2 redist
@jpreece6 did you install the runtime from here? https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads#windows-app-sdk-12
Can confirm, running the app once as admin works.
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:
<PropertyGroup><WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize></PropertyGroup>to disable the automatic code generation of the Deployment Manager by 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:
<PropertyGroup><WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize></PropertyGroup>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
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.
@mattleibow positive.
Here is what I did:
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:
It also logs another error with source “Application Error”:
And an Event Viewer Information entry:
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
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® Core™ i7-8750H CPU @ 2.20GHz 2.21 GHz
I can confirm this problem for MAUI Blazor Hybrid as well. Doesn’t matter for me if its in Release or Debug mode.
Update: I recreated the app targeting.NET 6, and it works just fine. Can even run via VS.
Yep, runtime version 1.2.1.2.221116.1
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:
Windows 10 Pro 22H2 Build 19045.2364
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.
Rollback VS version did not work for me, instead it led to a broken MAUI installation.
Same Problem here too !
In debug mode, they start for me, but in release mode, I also get an error
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 publishoutputs 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.
And it would be really great to get meaningful error messages. It seems that when the mix fails it fails silently.
On Tue, 14 Feb 2023, 3:44 pm Helmut Schmidt, @.***> wrote:
Of all suggested workarounds, these worked for me:
<WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize>in csprojAnd these did not work:
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?
@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. https://github.com/dotnet/maui/issues/10858#issuecomment-1380591739
Same here. Really appreciate it @mattleibow!
<WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize>worked for me @mattleibow . Thank youI 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. 👎
Thanks now its ok
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: @.***>
Same Problem here too!
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.
Running the app as admin first solved the problem for me (Windows 10, 21H2).
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
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).
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!
ok, so this looks like a Windows 10 Bug in combination with WinApp SDK 1.2.x which will be fixed in 2023
I have the same problem. The app deployment worked normally in VS 17.4.2.
Windows 10 22H2 Build 19045.2364