为什么 .NET Core 3 应用程序会在使用 Webview 时崩溃?

Why does .NET Core 3 app crash on Webview usage?

我将一个 WPF 应用程序迁移到 .NET Core 3 没有任何问题,如果我启动一个包含 WebView 的 WPF 表单,我会得到这个(内部)异常:

MissingManifestResourceException: Could not find the resource "Microsoft.Toolkit.Win32.UI.Controls.DesignerUI.resources" among the resources "Microsoft.Toolkit.Wpf.UI.Controls.DesignerUI.resources" embedded in the assembly "Microsoft.Toolkit.Wpf.UI.Controls.WebView", nor among the resources in any satellite assemblies for the specified culture. Perhaps the resources were embedded with an incorrect name.

我创建了一个示例存储库来重现 here

您在 5.1.1 版本中使用 WebView

<PackageReference Include="Microsoft.Toolkit.Wpf.UI.Controls.WebView" Version="5.1.1" />

在Nuget页面可以看到这个版本支持.NET Framework 4.6.2,所以不兼容.NET Core 3。

我看到有 6.0.0 预览版并且支持 .NET Core 3,所以你应该尝试一下,但它是预览版,所以可能会出现错误。