.NET SDK 是否不向后兼容旧的运行时?

Is the .NET SDK not backwards compatible with older runtimes?

我们已经在我们的机器上安装了 .NET 桌面 运行time 6.0.1。构建发生在 docker 容器中,图像构建在 mcr.microsoft.com/dotnet/sdk:6.0-windowsservercore-ltsc2022 上,显然已更新到 SDK 6.0.102。 现在我们的应用程序将在启动时崩溃并显示

Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'PresentationFramework, Version=6.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)

本地构建工作正常,我安装了 SDK 6.0.101。

项目中的目标框架定义为

<TargetFramework>net6.0-windows</TargetFramework>

所以我认为它应该 运行 在任何 .NET 6.0 上,而不仅仅是在 6.0.2 上,无论它是用哪个 SDK 构建的。 根据 MS Docs,它甚至应该在 6.1 上默认 运行,除非定义了不同的 <RollForward> 策略。

我们缺少什么?

编辑: 它一定是 WPF 的东西,因为构建在该容器上的控制台应用程序工作得很好......

这似乎是 .net 6.0.2 中的一个已知错误

见: https://github.com/dotnet/core/issues/7172#issuecomment-1034105137

您可以尝试以下解决方法: https://github.com/dotnet/winforms/issues/6663#issuecomment-1034371295

或者只使用 sdk:6.0.101-windowsservercore-ltsc2022 映像,直到发布固定版本