Skip to main content Skip to footer

Support for .NET Core 3.1 - ComponentOne WinForms and WPF

In the latest .NET Core version v3.1, Microsoft introduced numerous enhancements. The biggest enhancement announcement was support for desktop technologies, WinForms and WPF.

We're pleased to announce that with the 2020v2 release, ComponentOne for WinForms and WPF are fully compatible with the latest .NET Core version 3.1.

In this post, we'll share announcements relating to .NET Core 3.1 and describe how to use .NET Core 3.1 in any existing desktop application.

Support for .NET Core 3.1

For WinForms, ComponentOne had already started to support .NET Core 3.1 in 2020v1 hotfix release and with the latest 2020v2 release all .NET 4.5.2 WinForms/WPF controls are now .NET Core 3.1 compatible except for C1Editor control and the legacy controls.

Customers planning to port their .NET Framework based applications to .NET Core 3.1 should update to use the 2020v2 controls and continue developing their desktop applications using the most compatible WinForms/WPF controls.

What's New with .NET Core 3.1

Microsoft announced the .NET Core version 3.1 at the end of 2019 and the most highlighting feature was that the .NET Core v3.1 is a long-term supported (LTS) release and will be supported for three years. The next release after .NET Core 3.1 will be .NET 5 and it will be the only .NET platform meant for new applications going forward.

However, behind the scenes, .NET 5 is simply the next iteration of .NET Core 3.1, so by porting an application to .NET Core 3.1, you're preparing for the future of .NET 5, expected by November 2020. Hence, .NET Core 3.1 is an important link between .NET Framework based applications and the future .NET 5.

Being an industry leader in providing WinForms/WPF UI components, ComponentOne is taking strides to provide controls compatible with the latest framework updates, by supporting .NET Core 3.1.

ComponentOne WinForms and WPF Supports .NET Core 3.1

To demonstrate how any desktop application developed with .NET framework can be ported to .NET Core 3.1, let's discuss migrating the product sample 'Showcase' to .NET Core 3.1.

Migrating a Desktop Application to .NET Core 3.1

About the Sample

For this post, we'll be using one of our product samples 'Showcase', a Product Information Management WinForms application. To demonstrate the scenario, the application utilizes many of the latest enhancements in ComponentOne WinForms edition, like new Rules Manager control, themes and shows different operations with FlexGrid and Ribbon controls: searching, formatting, and data grouping.

This application is a standalone app and is one of the latest addition to the product samples repository shipped along with the product and can be found installed at location:

\Documents\ComponentOne Samples\WinForms\v4.5.2\C1FlexGrid\CS.

If you cannot find the Showcase sample at above location in your machine, please ensure to have installed the latest ComponentOne version and checking the 'Install Samples' option while running the product installer.

ComponentOne WinForms and WPF Supports .NET Core 3.1 ShowCase sample UI: FlexGrid, Ribbon, Themes and RulesManager, all together

Before porting the application to .NET Core 3.1, you need to do some preparation first.

Preparing to Port

  1. Install .NET Core 3.1 and Visual Studio 2019 version with .NET desktop development workload installed (Visual Studio 2017 only supports up to .NET Core 2.2).
  2. Start from a working solution. Ensure the solution opens, builds, and runs without any issues. Also, it is suggested to do the migration in a separate branch or, if you’re not using version control, create a copy of the project so you have a backup to go back to if necessary.
  3. Update NuGet packages to use the corresponding latest versions. It’s always a good practice to use the latest versions of NuGet packages before any migration.
  4. (Optional) Run the .NET Portability Analyzer to determine if there are any APIs your application depends on that are missing from .NET Core. If there are, you need to refactor your code to avoid dependencies on APIs, not supported in .NET Core.
  5. (Optional) Replace packages.config with PackageReference. If the project uses NuGet packages, you'll need to add the same NuGet packages to the new .NET Core project. .NET Core projects support only PackageReference for adding NuGet packages. You can learn more about this from a PackageReference article.

Porting the ShowCase application

Create a New Project

  1. Create a new application of the type WinForms, targeting .NET Core 3.1.
  2. Add all ComponentOne NugGet packages referred to in the original project. For the 'ShowCase' application, you'll need to add the following NuGet packages: C1.Win.C1Input, C1.Win.C1Themes, C1.Win.Ribbon, C1.Win.RulesManager, C1.Win.C1FlexGrid.ImportExport, C1.Win.C1SuperTooltip and C1.DataCollection.BindingList. Make sure to install the latest 2020v2 packages of the above assemblies.
  3. Build the project. At this point, if there are any issues with the packages, you will get a NuGet warning.

Modify Existing Project

Before modifying the original application, make sure to have a copy of the original .csproj file, you might need to use it in the future.

  1. Open the .csproj file of the original .NET Framework-based 'ShowCase' project and replace it with the .csproj file of the project created in the step above.
  2. In the top <PropertyGroup>, add the following statement:

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

  1. Build and run the application.

Running the application, you shouldn't receive any errors and with that, you’ve successfully migrated the WinForms project to .NET Core 3.1.

Note: The same steps are applicable for porting any existing .NET framework based WPF application.

Existing Caveats

Currently, the WinForms UI designer do not function in projects targeting .NET Core 3.1. So, it is not possible to drag & drop the component from VS toolbox to Windows forms.

What's Next

In addition to continuing support for .NET Core 3.1+, with the upcoming versions ComponentOne plans to make the .NET 5 controls come out of beta and officially support .NET 5. Also, MS is currently working on a new design-time model for .Net Core application and once it is stable, the ComponentOne WinForms designer might be available in one of the upcoming versions.

Please leave us your thoughts in the comments below, and happy coding!

Download Now!

Ruchir Agarwal

comments powered by Disqus