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."

Windows Forms Designer Preview 1
[Click on image for larger view.] Windows Forms Designer Preview 1 (source: Microsoft).

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.

comments powered by Disqus

Featured

  • Microsoft Eases Integration with Semantic Kernel AI SDK

    The basic idea is to provide unified API abstractions, especially for idiomatic C# code, to help platform developers and others work with any provider with standard implementations for caching, telemetry, tool calling and other common tasks.

  • Final .NET 9 Preview Ships with Go-Live License

    Visual Studio developers can now download the SDK for .NET 9 Release Candidate 2 with a go-live license, meaning devs get Microsoft support for production applications even before the framework reaches general availability next month.

  • Upcycle Your Old Laptops into a Kubernetes Cluster

    Learn about Windows-to-Linux conversions and how to break and fix cloud containers -- all while helping to save the world from e-waste with some "sheer geeky fun."

  • Visual Studio's Future: Live Help to 'AI-ify Your App'

    Visual Studio guru Mads Kristensen provided a peek into the IDE's AI future, explaining how while in live-coding it will identify opportunities for your own app to use AI to your advantage.

Subscribe on YouTube