question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

6.0.2 SDK update has broken WinForms apps

See original GitHub issue

ℹ️ UPDATE: Workaround here for those who need it.

. . .

There appears to be a critical problem with the new 6.0.2 update which makes apps compiled with it fail to start on machines running 6.0.1.

To reproduce, do the following:

  1. Visit Windows Update to update the runtime on your dev machine, and also update Visual Studio 2022 using Visual Studio Installer.
  2. On a client/test machine, install the 6.0.1 desktop runtime. Direct Link
  3. On your dev machine, create a new WinForms project, build it and copy the executable files to the client/test machine.
  4. Run it and it will not start. Event logs show the following:
Application: WinFormsApp1.exe
CoreCLR Version: 6.0.121.56705
.NET Version: 6.0.1
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileLoadException: Could not load file or assembly 'System.Windows.Forms, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'System.Windows.Forms, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   at WinFormsApp1.Program.Main()

This problem did not happen on .NET 5. I was under the impression patch versions are generally compatible with each other, and I use <RollForward>LatestPatch</RollForward> in my real app, but even with that setting it still crashes.

This is a blocking issue for me because if I distribute an update for my app built on 6.0.2 and the client is still running 6.0.1, that will be bad if the app suddenly stops working.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:35 (22 by maintainers)

github_iconTop GitHub Comments

4reactions
EatonZcommented, Feb 10, 2022

@RussKie Thank you, everything is back in a working state for me now. It seems like the best way to fix would be to put out a new update that doesn’t bump the versions / resets back to 6.0.0.0. Hopefully you can do that soon to avoid a lot of people compiling incompatible software on this version.

Full workaround steps for others who may need help:

  1. Make sure Windows and Visual Studio have installed the latest Patch Tuesday updates. Check Windows Update, and the Visual Studio Installer.
  2. Download and install the 6.0.1 SDK (64-bit download, 32-bit download).
  3. Create a global.json file with the contents @RussKie commented here, and put that file beside your project’s .sln file.

That’s it. When you debug your app you may notice it’s still loading 6.0.2 DLLs, but when you run the app on a system with the 6.0.1 runtime, it will work/not crash.

3reactions
DavidWisemancommented, Feb 16, 2022

If I run my .NET 6 app on a machine without .NET 6 installed, I’m prompted to install it which is great. If I later compile with 6.0.2 which happens automatically just by upgrading VS. Then the app fails silently. I have to check the event viewer for an error message - do some googling and try to figure out what the problem is.

If a newer runtime is required I don’t think it would be as big problem if it prompted you to install the new version. Or if this was treated as a new .NET framework version where you have to explicitly change the target framework in Visual Studio.

I guess this will be less of an issue over time as more clients have 6.0.2 installed. For now I don’t want to upgrade and will use the workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET February 2022 Updates – 6.0.2 and 5.0.14
NET Core Runtime, Windows Desktop Runtime, and SDK) have been offered via Microsoft Update to customers that opt in since December 2020.
Read more >
VS writes references to the latest installed .NET Core SDK ...
6.0.2 SDK update has broken WinForms apps. A solution that helped me was found here: Issue building with Windows Desktop 6.0.2.
Read more >
Eaton Z.
First P0 issue report for the WinForms repo . github.com. 6.0.2 SDK update has broken WinForms apps · Issue #6663 · dotnet/winforms....
Read more >
"You must install .NET Desktop Runtime 6.0.4 (x64)" error
I have created a simple Hello World application using Visual Studio 2022. The application is a WPF application that targets the .NET 6.0 ......
Read more >
Intro to Windows Forms (WinForms) in .NET 6
Windows Forms, also known as WinForms, is one of the original project types in .NET. It is designed to be a rapid application...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found