# Set up the license

> How-to guide: Set up the license in a client or server application: evaluation, entering the license key, querying the license, and checking it at startup.

> This content was machine translated and may contain errors. [Read in German](https://www.traeger.de/docs/development/opcua/license-setup)

**Sample applications:**

- App.LicenseUsage ([C#](https://github.com/Traeger-GmbH/opcuanet-samples/tree/master/cs/Scenarios/App.LicenseUsage), [VB.NET](https://github.com/Traeger-GmbH/opcuanet-samples/tree/master/vb/Scenarios/App.LicenseUsage)): This sample demonstrates how to apply the license keys of the SDK and how to protect them by string encryption when the application is obfuscated, here using Eazfuscator.NET.

This page shows how to set up the license of the OPC UA .NET SDK in your client or server application. The page [Licenses](https://www.traeger.de/en/docs/development/opcua/license) describes the available license models and SDK variants and how to handle the license key.

Types used: `Opc.UaFx.Licenser`, `Opc.UaFx.Client.Licenser`, `Opc.UaFx.Server.Licenser`, `ILicenseInfo`

## Evaluation

Without a license key, you can evaluate the SDK free of charge and without time limit: the trial license runs for **30 minutes per application start**, during which the SDK is available without restriction for client and server development. If 30 minutes per application start are not enough for you, you can request an extended evaluation from us. To do so, contact our support at [support@traeger.de](mailto:support@traeger.de). Our development team is also happy to advise you directly and answer open questions.

## Enter the license key

Once you have received your personalized license key, enter it in the SDK. The class that takes the key depends on the SDK variant:

| License | Class | Enter before first accessing |
|---|---|---|
| Client license | `Opc.UaFx.Client.Licenser` | `OpcClient` |
| Server license | `Opc.UaFx.Server.Licenser` | `OpcServer` |
| Bundle license (client and server) | `Opc.UaFx.Licenser` | `OpcClient` or `OpcServer` |

Add the matching line of code to your application **before** you access the class `OpcClient` or `OpcServer` for the first time. Replace `<insert your license code here>` with the license key you received from us.

### Client license

```csharp
Opc.UaFx.Client.Licenser.LicenseKey = "<insert your license code here>";

```

```vbnet
Opc.UaFx.Client.Licenser.LicenseKey = "<insert your license code here>"

```

### Server license

```csharp
Opc.UaFx.Server.Licenser.LicenseKey = "<insert your license code here>";

```

```vbnet
Opc.UaFx.Server.Licenser.LicenseKey = "<insert your license code here>"

```

### Bundle license

If you have purchased a bundle license key for client and server development from us, enter it like this:

```csharp
Opc.UaFx.Licenser.LicenseKey = "<insert your license code here>";

```

```vbnet
Opc.UaFx.Licenser.LicenseKey = "<insert your license code here>"

```

Once set, a **bundle license key takes precedence** over the client or server license key. If a bundle license key is set, the SDK checks the license against this key only. A client or server license key set in addition is then ignored.

## Query the license in use

The `LicenseInfo` property returns information about the license that the SDK currently uses. For client licenses, query it through the class `Opc.UaFx.Client.Licenser`, for server licenses through the class `Opc.UaFx.Server.Licenser`, and for bundle licenses through the class `Opc.UaFx.Licenser`. To query the license:

```csharp
ILicenseInfo license = Opc.UaFx.Client.Licenser.LicenseInfo;
 
if (license.IsExpired)
    Console.WriteLine("The OPC UA SDK license is expired!");

```

```csharp
ILicenseInfo license = Opc.UaFx.Server.Licenser.LicenseInfo;
 
if (license.IsExpired)
    Console.WriteLine("The OPC UA SDK license is expired!");

```

```vbnet
Dim license As ILicenseInfo = Opc.UaFx.Client.Licenser.LicenseInfo

If license.IsExpired Then
    Console.WriteLine("The OPC UA SDK license is expired!")
End If
```

```vbnet
Dim license As ILicenseInfo = Opc.UaFx.Server.Licenser.LicenseInfo

If license.IsExpired Then
    Console.WriteLine("The OPC UA SDK license is expired!")
End If
```

## Check the license at startup

During development and evaluation, it often does not matter whether the SDK still runs in evaluation mode or already with the purchased license. In production, however, an invalid license causes the application to stop working while it runs. We therefore recommend that you add the following code snippet to the application and run it at least when the application starts. The methods whose names begin with `FailIf` take effect only in debug builds (symbol `DEBUG`). The methods with `ThrowIf` take effect in all builds. Besides `ThrowIfUnlicensed`, `ThrowIfEvaluation`, `ThrowIfExpired`, and `ThrowIfSupportExpired` are also available:

```csharp
#if DEBUG
    Opc.UaFx.Client.Licenser.FailIfUnlicensed();
#else
    Opc.UaFx.Client.Licenser.ThrowIfUnlicensed();
#endif

```

```csharp
#if DEBUG
    Opc.UaFx.Server.Licenser.FailIfUnlicensed();
#else
    Opc.UaFx.Server.Licenser.ThrowIfUnlicensed();
#endif

```

```vbnet
#If DEBUG Then
    Opc.UaFx.Client.Licenser.FailIfUnlicensed()
#Else
    Opc.UaFx.Client.Licenser.ThrowIfUnlicensed()
#End If

```

```vbnet
#If DEBUG Then
    Opc.UaFx.Server.Licenser.FailIfUnlicensed()
#Else
    Opc.UaFx.Server.Licenser.ThrowIfUnlicensed()
#End If

```

For more information on licensing, purchasing, and other questions, see our product page [OPC UA SDKs](https://www.traeger.de/en/products/development/opcua).
