Skip to main content Skip to footer

How to Migrate from the .NET Framework to .NET 5 Controls

What is .NET 5.0

Microsoft's primary goal with the release of .NET 5.0 is to merge all future .NET development onto one unified .NET platform. All of Microsoft's different development environments, such as WinForms, WPF, ASP. NET, Xamarin, etc. are all moving to .NET Core, which will now be known as ".NET."

.NET 5.0 is technically .NET 5.0 Core, but 5.0 intends to clean up and simplify the terminology for future development in .NET. The version number is skipping straight from 3.0 to 5.0 to prevent confusion due to .NET Framework using the 4.x version numbering for quite some time now. After .NET 5.0,Microsoft's roadmap shows that they plan to keep the versioning simple with yearly major releases every November going from 5.0 to 6.0 to 7.0, and so on.

How to Migrate from dotNET to dotNET 5 Controls

Why Should I Upgrade to .NET 5.0

The ComponentOne team has outlined a few reasons .NET developers should consider upgrading to .NET 5:

  • To be on the cutting edge of Microsoft's platforms
  • To support multiple operating systems from one codebase
  • All platforms will be unified in supporting .NET 5.0
    • Master .NET 5.0, and you can work in any Microsoft platform
      • WinForms, WPF, ASP. NET MVC, Xamarin, etc.
  • Improved performance
  • Two runtime options
  • Java interoperability
  • Objective-C and Swift interoperability
  • New "Half" type
    • A binary floating-point that occupies 16 bits
  • Assembly trimming

Migrating from the .NET Framework to .NET 5.0

Before starting your migration, I recommend checking your project's portability with Microsoft's Portability Analyzer tool. This tool will give you an idea of how much trouble you may or may not have when migrating to .NET 5.0. Also, check out our guide on how to test if your app is portable to .NET5.

If you would like to follow along with my very simple example, download my starting sample.

  1. Create a New Folder for Your .NET Framework Project
  2. Create a New File and Add the Code
  3. Add the .csproj to the Existing Solution
  4. Configure the Project File to Include Code
  5. Add NuGet Packages

Step 1: Create a New Folder for Your .NET Framework Project

Create a new folder inside the main solution folder of your .NET Framework project that will contain the new .NET 5.0 project. Mine will be FlexGridOnNet5.

Step 2: Create a New File and Add the Code

Create a new file in the folder and name it yourprojectname.csproj then add the following:

<Project Sdk="Microsoft.NET.Sdk">  
  <PropertyGroup>  
    <TargetFrameworks>net5.0-windows</TargetFrameworks>  
    <UseWindowsForms>true</UseWindowsForms>  
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>  
    <AssemblyName>FlexGridOnNet5 (The name of your new 5.0 project)</AssemblyName>  
    <RootNamespace>FlexGridOnFramework (the name of your solution)</RootNamespace>  
  </PropertyGroup>

</Project>  

Step 3: Add the .csproj to the Existing Solution

Now let's add the new .csproj file to our existing solution. Open the command line in Visual Studio and use the following command:

dotnet sln add .\FlexGridOnNet5\FlexGridOnNet5.csproj

How to Migrate from dotNET to dotNET 5 Controls

Step 4: Configure the Project File to Include Code

Now we need to configure the project file to include all the code from our .NET Framework project. Instead of adding lines for each item, we can use this simple snippet to grab everything from the .NET Framework project.

  <ItemGroup>  
    <Compile Include="..\FlexGridOnFramework\**\*.cs" />  
    <EmbeddedResource Include="..\FlexGridOnFramework\**\*.resx" />  
  </ItemGroup>  

Step 5: Add NuGet Packages

Now we need to add NuGet Packages for anything we were using in our old project. In my case, I'll be adding C1.Win.C1FlexGrid

How to Migrate from dotNET to dotNET 5 Controls

That's it! You can find the finished sample here. Assuming your project doesn't currently rely on any APIs and are only available in .NET Framework, you should be good to go.

ComponentOne is .NET5 Ready

Update: The ComponentOne WinForms, WPF, Blazor, and ASP.NET Core controls are now all .NET5 ready, as of the 2020 v3 release. This includes designer support and new .NET5-built libraries available for WinForms and WPF. Learn more about the ComponentOne .NET5 controls and roadmap.


comments powered by Disqus