maui: [Bug] Can't run published WinUI app.
How to reproduce:
Create a new MAUI project (VS 16.11.0 preview 2)
Debug => Runs fine Publish => Running the published app Starts then exits with following error (from event viewer)
Application: MauiApp2.WinUI.exe CoreCLR Version: 6.0.21.30105 .NET Version: 6.0.0-preview.5.21301.5 Description: The process was terminated due to an unhandled exception. Exception Info: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) in System.Private.CoreLib.dll:token 0x600467f+0x4 at WinRT.BaseActivationFactory…ctor(String typeNamespace, String typeFullName) in Microsoft.WinUI.dll:token 0x6000023+0x6e at Microsoft.UI.Xaml.Application._IApplicationStatics…ctor() in Microsoft.WinUI.dll:token 0x6014cbd+0x1c at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000645+0x3e — End of inner exception stack trace — at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000645+0x4e at System.Activator.CreateInstanceT in System.Private.CoreLib.dll:token 0x6000963+0x0 at WinRT.WeakLazy`1.get_Value() in Microsoft.WinUI.dll:token 0x6000019+0x20 at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback) in Microsoft.WinUI.dll:token 0x6009b84+0x0 at MauiApp2.WinUI.Program.Main(String[] args) in C:\Users\mark\source\repos\MauiApp2\MauiApp2\MauiApp2.WinUI\obj\Release\net6.0-windows10.0.19041\win10-x64\Windows\App.g.i.cs:line 26
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 15 (2 by maintainers)
Same Problem here. I can run the project in Visual Studio 2019 Preview without any problems. But as soon as i build the executable and launch it, i get the same crash report in the windows event viewer.
.NET SDK Version: 6.0.100-preview.5.21302.13 Commit: d6380bcae7
Runtime: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.5.21302.13\
Host (useful for support): Version: 6.0.0-preview.5.21301.5 Commit: ec3e0b276b
.NET SDKs installed: 2.2.203 [C:\Program Files\dotnet\sdk] 3.1.410 [C:\Program Files\dotnet\sdk] 5.0.400-preview.21277.10 [C:\Program Files\dotnet\sdk] 6.0.100-preview.5.21302.13 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0-preview.5.21301.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0-preview.5.21301.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-preview.5.21301.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
环境 Microsoft Visual Studio Enterprise 2022 (64 位) - Preview 版本 17.1.0 Preview 1.1 MAUI Perview11
调试 Blazor MAUI 在 VS2022 中运行正常。
发布单文件时,我遇到了问题,怎么解决?
————————————————————————————————————————————— FolderProfile.pubxml
————————————————————————————————————————————— 输出
————————————————————————————————————————————— 弹窗
————————————————————————————————————————————— tmp36FD.tmp
—————————————————————————————————————————————
Visual Studio 2022 17.1.0 Preview 1 with .NET 6 and .NET MAUI Preview 10 doesn’t work either. ClickOnce has been removed, so I have attempted to publish to a folder for Windows, and that fails with the error:
RuntimeIdentifier ‘win-x64’ is invalid.
Publish Settings: Configuration: Release | x64 (I added this configuration as it was missing from the solution; NB: Any CPU doesn’t work either) Target framework: net6.0-windows10.0.19041 Deployment mode: Framework-dependent Target runtime: win-x64
I’ve tried win-x86 as well, that also fails.
In the previous iteration using Xamarin Forms, WPF was used as the host for Windows. That was much simpler; it’s more comfortable for .NET developers, as it more completely falls within the .NET space that we are used to working in. WinUI 3 is not, and I think it will be a lot more painful for developers not used to WinUI (or UWP before it perhaps.)
I wonder if it’s worth making WPF available as a host type in MAUI as well as WinUI. I think the use of WinUI 3 is going to cause a lot of friction. That might have a very negative impact on what otherwise promises to be a great technology - possibly to the point where a generation of developers are put off using it because of bad experiences that are nothing to do with MAUI itself.
There appear to be a few limitations to MAUI on Windows, caused by the use of WinUI 3 as the host. Publishing is definitely one of those.
I think the answer to your problem might be that you have limited publishing options available because of the host being WinUI 3.
I’ve created a test application from the maui-blazor template and tried to publish it using Visual Studio. Here is the outcome of the ways I have tried:
Publishing is definitely going to need some work for MAUI before launch, because the state of play at the moment isn’t workable. However, we’re in preview, and I completely understand that we should expect these bumps in the road at the moment, as making MAUI function at all has to come first!
Sidenote: the reason I was trying this is because I have found a permissions issue with running an application built with the experimental Mobile Blazor Bindings framework (a forerunner to MAUI using Blazor) when installed in the “Program Files” or “Program Files (x86)” folders. This is caused by the way the WebView2 component is initialised; by default WebView2 uses the application folder to store temporary files and this won’t work in the folders mentioned, as they are read-only to the application - they are not suitable locations for temporary files. As soon as we have a way to publish, we need to test whether we can install an application and have it work using WebView2.