【发布时间】:2021-08-18 06:29:12
【问题描述】:
我在带有 .NET 6.0.100-preview.7.21379.14 的 Windows 10 上使用 MSVS 2022 preview 3.1,我能够创建 MAUI 应用程序并将其部署到 Android 模拟器中。
我想在我的 Windows 上运行它,因为 Android 模拟器非常慢,而且我对桌面更感兴趣。目前这可能吗?我尝试构建 WinUI 项目,它在磁盘上创建了一个可执行文件,但是当启动该可执行文件时,什么也没有发生。
我尝试使用 Publish to Folder 来获得相同的结果。我尝试再次使用 Deploy,但结果相同。这两个过程都没有错误,只是在磁盘上创建的可执行文件什么都不做。
应用是使用dotnet new maui -n HelloMauiPreview 命令创建的。
编辑:
我已将登录 obj\Release\net6.0-windows10.0.19041\win10-x64\Platforms\Windows\App.g.i.cs 文件放入 Main,如下所示:
static void Main(string[] args)
{
global::WinRT.ComWrappersSupport.InitializeComWrappers();
global::Microsoft.UI.Xaml.Application.Start((p) => {
...
第一行执行没有问题,程序卡在第二行的某个地方。有一个没有被调用的代表。所以它卡在Start 的开始和调用该委托之间的某个地方。没有其他内容被执行,因此global::Microsoft.UI.Xaml.Application.Start 行之后的行不会被执行。
此外,当我说“卡住”时,应用程序不会挂在那里,它会以某种方式终止。使用事件查看器我发现了以下事件:
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 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 0x601388f+0x1c
at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x60006c8+0x3e
--- End of inner exception stack trace ---
at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x60006c8+0x4e
at System.Activator.CreateInstance[T]() in System.Private.CoreLib.dll:token 0x60009ed+0x0
at WinRT.WeakLazy`1.get_Value() in Microsoft.WinUI.dll:token 0x6000019+0x20
at Microsoft.UI.Xaml.Application._IApplicationStatics.get_Instance() in Microsoft.WinUI.dll:token 0x6013890+0x0
at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback) in Microsoft.WinUI.dll:token 0x6009288+0x0
编辑 2: 这个问题似乎与https://github.com/dotnet/maui/issues/1557
相似/相同【问题讨论】: