.NET Core 3.1 WindowsDesktop application can fail when rolled forward to .NET 5 preview
See original GitHub issue-
.NET Core Version: .NET Core 3.x -> .NET 5
-
Have you experienced this same bug with .NET Framework?: No
Problem description:
The System.Windows.Forms.Design.Editors.dll assembly has been removed in .NET 5, which can cause applications built with .NET Core 3.x to fail if they used a type from that assembly and are permitted to roll forward on major versions.
Expected behavior:
The application should not fail. Instead, a System.WinForms.Forms.Design.Editors.dll should be included that contains type forwards for all of the types that were moved out of that assembly. In this way, WinForms on .NET 5 remains binary compatible.
Minimal repro:
- Create a .NET Core 3 application.
- Add code that references a public type from
System.Windows.Forms.Design.Editors.dll, e.g.AnchorEditor. - Build it
- Run it
- Copy the app to a VM with only .NET5 SDK installed (or remove .NET Core 3.x SDK form your workstation)
- Modify a
<app name>.runtimeconfig.jsonwith the following content (update the .NET5 SDK version as necessary):{ "runtimeOptions": { "tfm": "netcoreapp3.0", "rollForward": "LatestMajor", "framework": { "name": "Microsoft.WindowsDesktop.App", "version": "5.0.0-preview.2.20119.5" } } } - Run the application and ensure that the code that used the type from
System.Windows.Forms.Design.Editors.dllexecutes.
[EDIT] updated the repro steps
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Troubleshoot app launch failures
Learn about common reasons for app launch failures and possible solutions.
Read more >Running .NET Core Apps on a Framework other than ...
1 app can run on 5.0. Although you can roll forward be aware that this may cause problems since major versions can have...
Read more >Visual Studio 2019 unable to locate .Net Core SDK
Step 1) First run dotnet --list-sdks from the command line (as in Grzegorz Smulko's answer). Take note of the greatest version number.
Read more >Windows Desktop Apps and .NET 5
This article describes the differences between .NET 5 and .NET Core 3.x and describes breaking changes from the upgrade. Overview of how to...
Read more >ASP.NET Core 3.1 Web application failed with 'Microsoft. ...
I noticed that in my project, under Dependencies\Frameworks, it listed both Microsoft.AspNetCore.App and Microsoft.NETCore.App , as one can see, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top 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

@RussKie @merriemcgaw just FYI if you intend to preserve binary compatibility between 3.x and 5.0 you cannot add proper generic collection support (#2644). Return types of GetEnumerator have to change in order for
foreachto pick it up; this will break applications which roll forward from 3.x (just tested). Since loops over collections are probably going to be pretty common you can’t treat it as an exceptional case, it’ll probably affect every nontrivial application rolling forward from 3.xIMHO requiring a recompile for 5.0 is not entirely unreasonable and its probably one of the better chances to modernize winforms, it’ll probably only get harder from there on.
So ultimately you’ll have to make a strategic decision here what your goal for the 3.x/5.0 transition is, and the sooner its done and communicated the better.
@RussKie I’m just saying that if #2644 is implemented the work done here doesn’t matter because roll-forward will fail anyways as soon as anyone has an
foreachloop (which is pretty likely). Giving people the false impression that roll-forward will work in “some cases” may be counterproductive because ensuring that nobody has an foreach loop over a WinForms collection will be pretty much impossible (its enough if a single library has such a loop). Personally I’d prefer a clear error message that you need to recompile (or dropping #2644 if the impact is considered too large). In either way I wanted to make sure you are aware of the consequences the not yet merged PR would have.You’ll have to make sure not using foreach loops over WinForms collections in the designer then (probably can pass the collection through a helper method so the foreach doesn’t see the specific class you are iterating over)