Sentinel® LDK Licensing API - C# .NET Core Sample for Windows, Linux, and macOS: Readme


This sample demonstrates how to use the .Net Core NuGet package (hasp_net_core.nupkg) to call Sentinel LDK Licensing API functions on various Windows, Linux, and macOS platforms.

Prerequisites

The .NET Core NuGet package included in this package was built with .NET Core 2.0.0.

To use hasp_net_core.nupkg, you require .NET Core Runtime 2.0.0 or later.

The latest .NET Core Runtime can be downloaded here:

https://www.microsoft.com/net/download/core#/runtime

Supported Operating Systems and Tested Compilers

Refer to the Sentinel LDK Release Notes - "Supported Platforms for Code Samples" and "Tested Compilers for Code Samples" sections.

Directory Structure

DotNet Core contains the following directory structure:

API

hasp_net_core.2.0.5.nupkg

The NuGet package for Licensing API. This contains all required class libraries and value types that provide access to Sentinel protection keys.

This also includes API dispatchers for hasp_net_core.dll and DEMO Sentinel Runtime libraries for the Windows and Linux operating systems described below.

Licensing_API_Net_Reference_English.html

Sentinel Licensing API .NET Class Library Reference Help Guide.

sample

bin

Contains precompiled .NET core sample binaries (including api dispatchers and demo runtime libraries) for Sentinel LDK Runtime API to be used with Windows, Linux Intel and Linux ARM operating systems.

Sample

Contains sample code source file to generate compiled binaries for Windows and Linux operating systems.

sample.sln

Solution file created with MicroSoft Visual C++ 2017 to compile source code. This file will work only with Visual C++ 2017 and later.

Usage Notes

This section describes how to set up and compile the sample.

To Add hasp_nt_core.nupkg to Your Windows Project

To use hasp_net_core.nupkg with any project created from Microsoft Visual Studio 2017 or later, install the hasp_net_core.nupkg package in your project as follows:

  1. Go to Tools > Options. From the Options menu, select NuGet Package Manager > Package Sources.
  2. Add the name (optional) and path for the new package source (where hasp_net_core.nupkg is copied) and click OK. hasp_net_core.nupkg is copied to the API folder.

    Options screen

  3. Right-click your project in the solution explorer and click Manage NuGet Packages.

  4. From the Package source list, select the newly-created package source (from Step 2).
  5. Select the hasp_net_core package from the Nuget Package Manager and click Install.

    hasp_net_core

  6. After the hasp_net_core.nupkg package has been installed in your project, it appears in the solution explorer

    Solutions list

Your .NET core project is now ready to be used with Sentinel Run-time APIs.

How to Run .NET Core Sample Compiled With hasp_net_core.nupkg

After successfully installing hasp_net_core.nupkg in your sample, publish your sample.

Solution Explorer

Publishing your project automatically places the API dispatchers and demo libraries for the Windows and Linux systems described below in the PublishOutput folder.

To use your own Batch Code:

  1. Copy your vendor specific libraries downloaded by Master Wizard to the PublishOutput folder.

  2. Copy the PublishOutput folder (from the bin\Release\ of your sample directory) to any supported platform.
  3. Ensure that the appropriate API dispatcher is present in the directory where the operating system's dynamic libraries reside.

  4. Ensure that your vendor-specific Sentinel Runtime API library is present in the following location:

    For Windows

    In one of the following locations:

    The following files must be present:

    For Linux

    In one of the following locations:

    The following files must be present:

    For macOS

    In one of the following locations:

    The following files must be present:

You can now execute the sample.

Troubleshooting

For Linux ARM, running the compiled .NET Core binary may give the error version 2.0.0 not found even if a later version for .NET Core is installed on the system. To overcome this error, simply edit the .runtimeconfig.json file in the directory that contains the compiled binaries, and change the value of the version attribute from 2.0.0 (shown below) to the exact version of .NET Core installed on your system. Rerun the sample.

{
  "runtimeOptions": { 
    "tfm": "netcoreapp2.0",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.0.0"
    }
  }
}

For any troubleshooting regarding the error codes or usage of classes/namespaces that are part of the hasp_core.net library, refer to the Sentinel Licensing API Reference Guide included in the API folder.

Copyright © 2022 Thales Group. All rights reserved. Support   

DocID 247 Revision 2204-2