News
Visual Basic in .NET 5: Ready for WinForms Apps
With the milestone .NET 5 and Visual Studio 2019 v16.8 releases now out, Microsoft is reminding Visual Basic coders that their favorite programming language enjoys full support and the troublesome Windows Forms Designer is even complete -- almost.
While .NET 5 and VS 2019 v16.8 are being lauded for their cross-platform support and latest-and-greatest functionality for creating modern cloud, mobile, AI, IoT and other apps in C#, there are a lot of coders out there still wrestling with developing good old-fashioned Windows desktop apps with VB, which Microsoft isn't even advancing any more.
Case in point: When Microsoft shipped Release Candidate 1 for .NET 5 back in September, a reader posted a comment on the announcement blog, stating: "Any updates on VB.Net WinForms?"
Microsoft's Kathleen Dollard replied:
"We are tying up loose ends:
- The templates will be in RC2, we're still settling on some issue around HighDPI.
- Project Properties updates will be in the next Visual Studio preview.
- I think the fix to the terrible, awful Event Handler designer bug made RC1, if not, it's fixed in RC2 (where double clicking a control gives you a new handler even if one exists)
"So, look for RC2! As well as blog post(s) around that time."
And, today (Nov. 23) such a blog post has finally been published.
"While .NET Core has had Visual Basic since the first release, and WinForms since it was released in .NET Core 3.1, it did not include the Application Framework library and WinForms Designer support Visual Basic programmers expect," Microsoft's Klaus Loeffelmann said in that post. ".NET 5 is the next version of .NET Core and we think .NET 5 is ready for you to migrate existing .NET Framework apps or create new WinForms applications."
Microsoft back in March announced that VB support was planned for .NET 5, making the leap from the previous .NET Core series of frameworks that launched the old, Windows-only .NET Framework in its new modern, open source, cross-platform edition. Specifically, it said that with .NET 5, VB will support:
- Class Library
- Console
- Windows Forms
- WPF
- Worker Service
- ASP.NET Core Web API
However, transferring some desktop dev functionality from .NET Framework to .NET Core proved troublesome, presenting the dev team with a "huge technical challenge for some components, especially the WinForms Designer.
"For developers the .NET Core Windows Forms Designer (when we will release the GA version) will look and feel the same as the .NET Framework Windows Forms Designer," said Olia Gavrysh, program manager, .NET. "But for us it is a huge technical challenge to bring the designer to .NET Core because it requires the design surface that hosts the live .NET Core form to run outside the Visual Studio process. That means we need to re-architect the way the designer surface 'communicates' with Visual Studio."
And, even though Loeffelmann deemed VB ready to go in .NET 5 and VS 2019 v16.8, he seemed to indicate that the delays caused by the aforementioned "huge technical challenge" are still being felt, presented under the category of "known issues."
"In Visual Studio 16.8, the WinForms Designer still has a few features missing," he said. "Also, the project system, which manages the Project Dialog, does not fully support the Application Framework."
Other than those, he noted that VS 2019 16.8 and .NET 5 include these updates for WinForms development in .NET 5:
- Designer Event Handling support: Visual Basic events are hooked up with
a Handles keyword on the code behind method. This presented significant
challenges to the WinForms designer and did not work correctly in .NET Core
3.1. This has been fixed.
- Application Framework: The Visual Basic Application Framework provides
event-based startup, meaning you don't need a
Sub Main
for WinForms
applications. A new version of the Application Framework is available in
.NET 5. - Single Instance applications: .NET 5 introduces Single Instance
Applications to the .NET Core family. The new version also has updated logic
that should work well in more scenarios.
- Updates to Visual Studio dialogs: Updates have been made to a few
dialogs to support Visual Basic features in the new project format. This
work is ongoing.
- Visual Basic WinForms template: We waited to add the template to Visual
Studio until you could create WinForms applications with the Application
Framework. This new template is the default in Visual Studio, and available via a switch on
dotnet new
in the .NET CLI. - Additional Visual Basic Runtime features: The last few versions of .NET
Core have ported features of the Visual Basic Runtime. We believe this work
is complete and that missing features can't work the same way on .NET 5.
"We're excited about the updates for Visual Basic in .NET 5, but first a reminder that you can base your decision to migrate to .NET 5 on whether or not you want its new features and how you need to interop with .NET 5 applications," Loeffelmann said. "The .NET Framework will be supported as part of Windows for a very long time. New features will not be added to .NET Framework. New features, including new WinForms features, will be added only to .NET 5 and future versions."
Read the post for more details on:
- Creating .NET 5 Application Framework WinForms apps in Visual Studio
- Differences from .NET Framework
- New Application Framework Event ApplyHighDpiMode
- Creating .NET Core 3.1 or .NET 5 VB WinForms Apps with the CLI
- Changed Project File format
About the Author
David Ramel is an editor and writer for Converge360.