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.
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
Refer to the Sentinel LDK Release Notes - "Supported Platforms for Code Samples" and "Tested Compilers for Code Samples" sections.
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.
This section describes how to set up and compile the sample.
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:
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.
Select the hasp_net_core package from the Nuget Package Manager and click Install.
After the hasp_net_core.nupkg package has been installed in your project, it appears in the solution explorer
Your .NET core project is now ready to be used with Sentinel Run-time APIs.
After successfully installing hasp_net_core.nupkg in your sample, publish your sample.
Publishing your project automatically places the API dispatchers and demo libraries for the Windows and Linux systems described below in the PublishOutput folder.
Ensure that the appropriate API dispatcher is present in the directory where the operating system's dynamic libraries reside.
Ensure that your vendor-specific Sentinel Runtime API library is present in the following location:
For Windows
In one of the following locations:
In the process directory (where the application executable resides)
DLL directory (where the .NET DLL resides, if any)
In the Windows System directory
In the Windows directory
The following files must be present:
For Windows x86: apidsp_windows.dll and hasp_windows_xxxx.dll
For Windows x64: apidsp_windows_x64.dll and hasp_windows_x64_xxxx.dll
For Linux
In one of the following locations:
In the process directory (where the application executable resides)
In one of the directories specified in the LD_LIBRARY_PATH variable
In /var/hasplm, /usr/local/lib, or /usr/lib64
The following files must be present:
For Linux Intel x64: libapidsp_linux_x86_64.so and libhasp_linux_x86_64_xxxx.so
For Linux armhf: libapidsp_linux_armhf.so and libhasp_linux_armhf_xxxx.so
For Linux arm64: libapidsp_linux_arm64.so and libapidsp_linux_arm64_xxxx.so
For macOS
In one of the following locations:
In one of the directories specified in the LD_LIBRARY_PATH variable
In the process directory (where the application executable resides)
Inside the application bundle
In one of the directories specified in the DYLD_FALLBACK_LIBRARY_PATH variable
In /var/hasplm, /usr/local/lib, or /usr/lib
The following files must be present:
apidsp_darwin.dylib and hasp_darwin_xxxx.dylib
You can now execute the sample.
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