> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/feature-management-experimentation/new-to-fme/sdks-and-customer-deployed-components/openfeature-providers/net-sdk.md).

# OpenFeature Provider for .NET SDK

Integrate your .NET applications with Harness FME using the .NET OpenFeature Provider, a standardized, vendor-agnostic feature flagging API. This provider implements the OpenFeature specification and bridges the OpenFeature SDK with the Harness FME .NET SDK.

This page walks you through installing, configuring, and using the .NET OpenFeature provider to evaluate feature flags in your .NET applications.

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

Before you begin, ensure you have the following:

* A valid [Harness FME SDK key](/feature-management-experimentation/new-to-fme/sdks-and-customer-deployed-components.md#api-keys) for your project
* A .NET 6.0+ environment
* Access to your project file to install NuGet dependencies

### Version compatibility <a href="#version-compatibility" id="version-compatibility"></a>

| Component                                          | Minimum Version |
| -------------------------------------------------- | --------------- |
| .NET Runtime                                       | 6.0+            |
| `@splitsoftware/split-openfeature-provider-dotnet` | ≥ 1.0.0         |
| OpenFeature .NET SDK                               | ≥ 1.0.0         |

### Install the provider and dependencies <a href="#install-the-provider-and-dependencies" id="install-the-provider-and-dependencies"></a>

Install the Harness FME OpenFeature provider from [NuGet](https://www.nuget.org/packages/Splitio.OpenFeature.Provider/):

```bash
dotnet add package Splitio.OpenFeature.Provider
```

### Initialize the provider <a href="#initialize-the-provider" id="initialize-the-provider"></a>

You can register the provider with OpenFeature by initializing using an SDK key directly or providing a pre-configured Split client.

{% tabs %}
{% tab title="SDK API Key" %}
If you are using an SDK API key:

```csharp
using OpenFeature;
using Splitio.OpenFeature.Provider;

Api api = OpenFeature.Api.Instance;
api.setProviderAsync(new Provider("<YOUR_SDK_API_KEY>"));
```

{% endtab %}

{% tab title="Split Factory (Recommended)" %}
If you are using a Split Factory:

```csharp
using OpenFeature;
using Splitio.OpenFeature.Provider;
using Splitio.Services.Client.Classes

Api api = OpenFeature.Api.Instance;

var config = new ConfigurationOptions
{
   Ready = 10000
};
var splitClient = new SplitFactory("<YOUR_SDK_API_KEY>", config).Client();
api.SetProviderAsync(new Provider(splitClient));
```

Using a configured `SplitFactory` is recommended for production systems since it allows customization of timeouts, impressions mode, and additional behavior.
{% endtab %}
{% endtabs %}

### Construct an evaluation context <a href="#construct-an-evaluation-context" id="construct-an-evaluation-context"></a>

Provide an evaluation context with a targeting key to evaluate flags. The evaluation context passes targeting information such as user IDs, email addresses, or plan types for flag targeting.

For example:

```csharp
var context = EvaluationContext.Builder()
   .Set("targetingKey", "randomKey")
   .Build();

var result = await client.GetBooleanValueAsync("boolFlag", false, context);
```

If the same targeting key is reused across evaluations, set the context at the client level:

```csharp
client.SetContext(context)
```

Or at the API level:

```csharp
api.setEvaluationContext(context)
```

Once the context is set at the client or API level, you don't need to provide it for each evaluation.

For more information, go to the [Harness FME .NET OpenFeature Provider GitHub repository](https://github.com/splitio/split-openfeature-provider-dotnet).
