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:
- Visit Windows Update to update the runtime on your dev machine, and also update Visual Studio 2022 using Visual Studio Installer.
- On a client/test machine, install the 6.0.1 desktop runtime. Direct Link
- On your dev machine, create a new WinForms project, build it and copy the executable files to the client/test machine.
- 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:
- Created 2 years ago
- Reactions:3
- Comments:35 (22 by maintainers)
Top 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 >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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:
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.
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.