Skip to main content Skip to footer

Using ComponentOne Winforms Controls with the NuGet Package Manager

Starting with our 2019 v3 release, all ComponentOne Winforms 4.5.2 .NET Framework controls are available via NuGet for use in .NET Framework and .NET Core Winforms projects.

NuGet is a package manager integrated into Visual Studio. It makes adding and updating new tools and features into your projects quick and easy. When you add a NuGet package to your solution, it integrates into that project's references and becomes available in your toolbox to add to a form.

Configure NuGet Package Manager

We publish our packages to the public Nuget.org server so anyone can find them. The address should already be configured in your Visual Studio. For access, go to: Tools > NuGet Package Manager > Package Manager Settings and then selecting “Package Sources.”

Using ComponentOne Winforms Controls with the NuGet Package Manager

Using ComponentOne Winforms Controls with the NuGet Package Manager

The default https://www.nuget.org/api/v2/ should already be configured.

Configuring a Local NuGet Repository

You can configure a local NuGet repository and point it to the local or network directory where you store your .nuget files. We include a copy of all our packages in the C:\Program Files (x86)\ComponentOne\Packages folder. Add your own by clicking the + at the top of the Package Sources window. Provide a name and configure the path to the directory.

Using ComponentOne Winforms Controls with the NuGet Package Manager

Note: it’s preferable to use the online repositories as it will enable to you to quickly access new releases and features. The local repository is best if you have an offline machine and can’t access nuget.org.

Using NuGet Package Manager

To add a Nuget package to your application, select Tools > NuGet Package Manager > Manage NuGet Packages for Solution

Using ComponentOne Winforms Controls with the NuGet Package Manager

When the window opens, choose the “Browse” option in the top left corner. Search for the control you want in the search box. For example, “C1 Winforms FlexGrid.”

Using ComponentOne Winforms Controls with the NuGet Package Manager

Select the control and then checkmark the project on the right that you wish to add the control to. You can choose different releases from the version dropdown and then click “Install.”

Using ComponentOne Winforms Controls with the NuGet Package Manager

Click “OK” on the preview changes dialog.

Using ComponentOne Winforms Controls with the NuGet Package Manager

Click “I Accept” on the License Acceptance dialog.

Using ComponentOne Winforms Controls with the NuGet Package Manager

The Control is now added to your toolbox and the necessary references added to your project.

Using ComponentOne Winforms Controls with the NuGet Package Manager

Drag the control onto the form just like you would with a traditional install of ComponentOne controls.

Updating Using the NuGet Package Manager

To update the ComponentOne controls in your application, follow these steps:

  1. Launch the NuGet Package Manager and select the “Installed” option at the top
  2. Select the C1 control you want to update, select the new version in the “Version:” dropdown on the right, and click Update
  3. Confirm the changes and accept the license agreement for NuGet

In the example screen below, we go from 4.5.20193.398 to the 4.5.20201.416 version.

Using ComponentOne Winforms Controls with the NuGet Package Manager

Using the NuGet Package Manager Console

If you prefer CLI interfaces, install and update your NuGet packages with the NuGet Package Manager Console. To launch the console, click Tools > NuGet Package Manager > Package Manager Console.

Using ComponentOne Winforms Controls with the NuGet Package Manager

The console opens by default in the same lower window as your error and output lists.

Using ComponentOne Winforms Controls with the NuGet Package Manager

To install a package, use the command Install-Package and the package name, in our case, we use:
Install-Package C1.Win.C1FlexGrid

Using ComponentOne Winforms Controls with the NuGet Package Manager

This executes and installs the latest version available. Note, you will not get the confirmation or license agreement prompts with the command line version. The control now appears in your toolbox and references and using the control works the same way.

You can alternatively specify a version to install with a -version switch.

Using ComponentOne Winforms Controls with the NuGet Package Manager

Updating Using the NuGet Package Manager Console

Update via the console using the Update-Package command. In the example above, we installed the .NET 4.5.2 2019 v3 build .398 version. We can update to the latest version using:

Update-Package C1.Win.C1FlexGrid

This updates the control and any dependences to the latest version. Specify a -version switch if needed in the Update-Package command.

NuGet Package Manager Conclusion

The NuGet Package Manager is a powerful and versatile tool and works great with controls and tools like those found in ComponentOne Studio.

Licensing for our controls works the same regardless if you load them into your toolbox via the C1ControlPanel or via NuGet. When you drag and drop a control from the toolbox onto a form, it checks for a C1 license on your machines and creates a 30-day trial key if it doesn’t find one. Then it creates or updates the licenses.licx for that control.

While NuGet can update the version of the controls referenced in your application, it cannot update your project’s licenses.licx. This may lead to a potential mismatch resulting in an evaluation nag screen. We provide tools in our GrapeCity License Manager that resolve these issues.

Find more information about managing your licenses with ComponentOne controls here.

We hope this gives you a good introduction to the NuGet Package Manager.

If you have any questions, please feel free to leave a comment below.

Andy Paxinos

Junior Product Manager
comments powered by Disqus