Skip to main content Skip to footer

Get Started with ComponentOne WinForms and .NET Core 3.0

With the release of the .Net Core 3.0 preview, we have had users asking about our direction. Our desktop libraries including WinForms will support .NET Core 3.0. At present, we have been busy researching the changes and compatibility of the framework and our libraries. The good news is, no changes will be required to use the controls in .Net Core 3.0. However, there are some controls that currently do not work in preview1 because of some missing classes. We have reported this and have been told that they are in process to be ported. To learn about open issues please jump to the last section of this blog.

Now, let's see how to port one of the samples to .NET Core 3.0. This will demonstrate that we do not need many changes in our project. The steps are similar to those mentioned on GitHub.

Prerequisites

  1. Install .NET Core 3.0 SDK here. Choose an appropriate platform to download the installer - x64 if you have a 64-bit version system and x86 if you have a 32-bit system.

  2. The steps in this walkthrough use VS2019; it can be installed side by side. You can download the preview here.

  3. Install ComponentOne WinForms Edition with samples (get your free trial here). You can skip this step if you already have it installed.

Step 1

The tooling in VS2019 is currently limited. Because the project templates for WinForms are missing, we will use the command prompt to create a new project. Open a command prompt and run the following:

dotnet new winform -o TestWFCore

This should create a new project named TestWFCore. The project is located under c:\Users(YourAccount)\

Navigate to the project directory through the command prompt

cd TestWFCore

Step 2

Add the Windows Compatibility package through command prompt as follows:

dotnet add package Microsoft.Windows.Compatibility

Step 3

Run the application using dotnet run to ensure that project works correctly.

dotnet run

Hello .NET Core

The project can build and run. Now we can open it in Visual Studio.

Project in Visual Studio

Step 4

We are going to run an existing sample in .NET Core 3.0, we will port the "ComboBoxItemModes" Input sample available at this location:

~\Documents\ComponentOne Samples\WinForms\C1Input\CS\ComboBoxItemModes

Link all of the csharp files from the above sample to this project. Include the licences.licx as well, it is located under the Properties folder.

Mark the licenses.licx file as embedded resource.

Most existing projects include an AssemblyInfo.cs file in the Properties folder. The new project style uses a different approach and generates the same assembly attributes as part of the build process. To disable that behavior, you can add the property GenerateAssemblyInfo:

<PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <generateassemblyinfo>false</generateassemblyinfo>
</PropertyGroup>   

Step 5

Add reference for C1.Win.Input assembly.

Step 6

Modify the program.cs file to create instance of Form1 and run the application. This is similar to any WinForms app.

 class Program
    {
        static void Main()
        {
          Application.Run(new Form1());
        }
    }

Step 7

Build and run the application: Build and Run the Application

Reference sample

We have created a simple sample which shows different controls running in .NET Core 3.0; this sample is attached for your reference. Check out the readme file before running the sample. You will find the .NET Core 3.0 project file under: ~ \DotNetCore3Sample\WinForms\CS\DotNetCore3\DotNetCore3

.NET Core 3 Sample

Issues in .NET Core 3.0 Preview 1

Currently, FlexGrid, TrueDbGrid, ThemeController and Command have problem running in .NET Core 3.0 preview 1 due to classes that are yet to be ported. The following tickets have been raised, these should get fixed in next previews:

https://github.com/dotnet/corefx/pull/33452 https://github.com/dotnet/corefx/issues/26745

Please share issues you face while trying the controls in .NET Core 3.0. This will help us in improving the controls.

Happy Coding!

Prabhakar Mishra

Prabhakar Mishra

Product Manager
comments powered by Disqus