Skip to content

.NET SDK — install and configure

The .NET client SDK embeds MonetizeIt into your application: it activates a license, tells you what the current license permits, and reports what gets used. Everything it does is also available over the REST API — the SDK is the convenience layer for .NET.

The SDK ships as NuGet packages. Most applications need two:

Terminal window
dotnet add package Revenusion.MonetizeIt.Client.LicenseConsumer
dotnet add package Revenusion.MonetizeIt.Client.AspNetCore
  • Client.LicenseConsumer — the licensing engine (activation, validation, usage). Targets netstandard2.0, so it runs on .NET Framework, .NET 8+, MAUI, and Unity.
  • Client.AspNetCore — dependency-injection wiring, the authenticated HTTP client, and the background usage reporter for host-based apps.

For disconnected devices, add Client.OfflineStore.

Two configuration sections drive the SDK. MonetizeIt:Tenant says which tenant to talk to and with what credentials; MonetizeIt:LicenseConsumer says how licenses behave on this machine.

{
"MonetizeIt": {
"Tenant": {
"HostName": "example.com",
"TenantName": "acme",
"LicenseConsumerClientId": "your-app-client-id",
"LicenseConsumerClientSecret": "your-app-client-secret",
"LicenseConsumerScopes": "provision.usage.* provision.session.*"
},
"LicenseConsumer": {
"LicenseKey": "the-license-key-for-this-install",
"PublicKey": "<base64 provider public key>",
"License": { "AllowUnsignedLicenses": false },
"Scheduler": {
"UsageReportingIntervalSeconds": 60,
"LicenseRefreshIntervalSeconds": 300
}
}
}
}

HostName + TenantName resolve to your tenant endpoint (https://acme.example.com). The client id, secret, and scopes come from API Credentials in the admin portal — create a client for your application there.

builder.Services
.AddMonetizeItHttpClientWithAuthentication(builder.Configuration)
.AddMonetizeItLicenseConsumer(builder.Configuration);

AddMonetizeItLicenseConsumer registers ILicenseSession (scoped) as the entry point your code uses. AddMonetizeItHttpClientWithAuthentication gives it an HTTP client that authenticates with the credentials above.

Licenses are signed by the provider. The SDK verifies that signature with the provider’s public key, so a tampered or forged license is rejected. Obtain the key once from the admin API — GET /api/v1/provision/admin/providers/license-signing-key — and set it as MonetizeIt:LicenseConsumer:PublicKey.

If no key is configured, the SDK refuses to start rather than silently trusting unverified licenses — a licensing runtime that fails open is not enforcing anything. The only escape hatch is License:AllowUnsignedLicenses = true, intended for transport-authenticated test setups, never production.

A single-install application sets LicenseKey (and optionally NodeId) in configuration. An application that serves many customer tenants from one process supplies the license key per request instead: register your own scoped ILicenseKeyProvider before calling AddMonetizeItLicenseConsumer, and resolve the key from the current request’s tenant.

builder.Services.AddScoped<ILicenseKeyProvider>(sp =>
StaticLicenseKeyProvider.Create(CurrentTenant.LicenseKey));

The same pattern applies to INodeIdProvider when each tenant needs a distinct device identity. See device fingerprints.

Desktop and plain-.NET applications that don’t run a generic host build the client directly. LicenseClientBuilder assembles it from small parts — what identifies the license, what identifies the device, where to cache, and how to talk to the API:

using Revenusion.MonetizeIt.Client.LicenseConsumer;
var client = new LicenseClientBuilder()
.UseMonetizeItHttpClient(httpClient) // points at your API base URL
.UseLicenseKey(StaticLicenseKeyProvider.Create(code)) // the activation code
.UseNodeId(new DeviceIdDeviceFingerprint()) // the device fingerprint
.UsePublicKey(base64PublicKey) // pin the signing key
.UseLicenseStoreBuilder() // cache the license on disk
.UseSystemInfo() // report OS/app diagnostics
.Build();
var session = client.Session;

Build() returns an ILicenseClient: it owns the background schedulers (usage upload, scheduled reporting), exposes the Session, and is IDisposable — keep it for the application’s lifetime and dispose it on shutdown. Call FlushAsync() to push pending usage before exit. BuildSession() is a shortcut when you only want the ILicenseSession.

The provider key requirement applies here too: the builder refuses to build unless you pin the public key with UsePublicKey or explicitly opt out via LicenseConfiguration.AllowUnsignedLicenses.

From here on, everything is identical to the hosted path — the same ILicenseSession, the same activation, entitlement checks and usage reporting.

If you want thin HTTP wrappers instead of the full consumer, Revenusion.MonetizeIt.Client.Provisioning exposes them directly:

  • LicenseActivationApiFetchJwtByActivationCode, FetchLicense, RenewLicense, CheckIn, CheckOut.
  • UsageApiProcessTransactionsForSession, ProcessTransactionsForEntitlement, TryConsume, AssetConsumption, AssetUsage, GetRatingPrompt.

They map one-to-one onto the REST endpoints and share the authentication providers.