Licensing in .Net


The following article details the process of embedding a .NET license at compile time to allow for deployment to external machines. For .NET Standard/.NET Core licensing, please see the section at the bottom of the article.

If a license is not properly embedded, deploying an application built with our components may result in errors like "could not find a valid license," or, if a trial license was installed on the deployment machine at some point, "trial license has expired."

To license the components in your project there are two options: The standard Microsoft .NET licensing approach, or the Runtime License approach which uses a hard-coded value. When using .NET Standard/.NET Core, the Runtime License approach must be used.

Contents

.Net Framework

Our .NET Edition components use Microsoft's .NET Licensing scheme. This is where a file named "licenses.licx" is added to your project as an embedded resource. This licx file gets used at compile time to embed the license into your compiled assembly.

WinForm, Console, and other project types

When dropping controls onto the form in Visual Studio, they are automatically added to the "licenses.licx" file.

If you are not using a form, or you are creating the components dynamically, you should create the "licenses.licx" file manually. It is a text file consisting of one line for each licensed component, where each line contains the component name and the library name. For example, if you were using the FTP component from the nsoftware.IPWorks.dll, your licx file should contain the following line:

nsoftware.IPWorks.Ftp, nsoftware.IPWorks

The newly created licenses.licx file should then be added as an embedded resource in your solution.

By default, Visual Studio adds some other information (version, culture, etc) which, if you are having licensing problems, should be removed so that only these two pieces of information are included.

Web Projects

If you are developing a web site application in Visual Studio, the license information is held in the App_Licenses.dll file which should be distributed alongside your application. This file is automatically generated when dragging controls onto the form in design mode. Alternatively, you can manually generate this file by right clicking on the licenses.licx file from solution explorer and selecting "Build Runtime Licenses". If your project does not have a licenses.licx file, it can be manually created by the process described in the previous section.

Additional Notes

  • If you are developing a class library, the referencing project must also include the .licx file as an embedded resource and be compiled on a machine with a valid license installed.
  • There is an issue with Visual Studio .NET where the licenses.licx file is not properly matched to the project if the name of the project contains whitespace. If the name of your project does contain whitespace characters, please remove them or replace them, then rebuild your project.

There have been rare cases where licensing problems persist after following the above steps correctly. In these cases, it is recommended to use the Runtime License scheme described below.

Runtime License

As an alternative to the Microsoft .NET Licensing schema the RuntimeLicense property can be used to hard-code a license to the component instance. This is a simpler approach, but does require a constant string value to be assigned in code. To use the RuntimeLicense property you must first obtain the value from a properly licensed development machine. To find this value, output the RuntimeLicense property of any component on a properly licensed development machine. For instance:

Console.WriteLine(ftp.RuntimeLicense);

This will output a long string. This string is your runtime license and should be hard-coded as the RuntimeLicense value for each component instance in your project. For instance:

Ftp ftp = new Ftp(); ftp.RuntimeLicense = "value from above";

On a licensed development machine this may look strange; the RuntimeLicense value is printed out and then immediately set to the same property name. However, this ensures that the RuntimeLicense value is valid once the application is deployed to a non-licensed machine.

The runtime license value is the same for each component in the toolkit. If you are using multiple toolkits you will need to output and use the runtime license for each toolkit. For instance if you are using both IPWorks and IPWorks SSH, all of the components in IPWorks will use one runtime license value and all of the components in IPWorks SSH will use another runtime license.

Note: If you are developing a component library separate licensing is required. Please contact support@nsoftware.com for details.

.NET Standard/.NET Core

A license must be activated before the .NET Standard library can be used. To activate a license use install-license, a .NET Core application included with the library.

If the library was installed from a NuGet package, this application is present in the tools folder in the package installation directory. Typically the package can be found here on Windows: %USERPROFILE%\.nuget\packages\nsoftware.ipworks

If the library was installed as part of the .NET Edition, the application is present in the lib\netstandard2.0 folders of the installation directory.

To use the install-license application run the command:

dotnet ./install-license.dll key

Where key is your product key. This will install a license on the particular system.

Trial Licensing in .NET Standard

If no key is provided to the install-license application, a trial license will be installed.

When using a trial license in non-desktop environments such as Universal Windows Platform (UWP), Xamarin.iOS, and Xamarin.Android no special steps are required; simply create and use the component. UWP Fall Creator's Update and Later requires the trial license to be included as an embedded resource. From the solution explorer in Visual Studio add an existing item to the project and add %USERPROFILE%\.nsoftware\IPNBA.lic. Set the Build Action property for the file to Embedded Resource

Deployment

In .NET Standard/.NET Core the RuntimeLicense property must be used to hard-code a license to the component instance. To use the RuntimeLicense property you must first obtain the value from a properly licensed development machine. To find this value, output the RuntimeLicense property of any component on a properly licensed development machine. For instance:

Console.WriteLine(ftp.RuntimeLicense);

This will output a long string. This string is your runtime license and should be hard-coded as the RuntimeLicense value for each component instance in your project. For instance:

Ftp ftp = new Ftp(); ftp.RuntimeLicense = "value from above";

On a licensed development machine this may look strange; the RuntimeLicense value is printed out and then immediately set to the same property name. However, this ensures that the RuntimeLicense value is valid once the application is deployed to a non-licensed machine.

The runtime license value is the same for each component in the toolkit. If you are using multiple toolkits you will need to output and use the runtime license for each toolkit. For instance if you are using both IPWorks and IPWorks SSH, all of the components in IPWorks will use one runtime license value and all of the components in IPWorks SSH will use another runtime license.

Note: If you are developing a component library separate licensing is required. Please contact support@nsoftware.com for details.

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.