---
title: "Installing or upgrading to v2 C# SDKs"
slug: "installing-or-upgrading-to-v2-csharp-sdks"
updated: 2026-04-15T11:48:46Z
published: 2026-04-15T11:48:46Z
canonical: "support.lusid.com/installing-or-upgrading-to-v2-csharp-sdks"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.lusid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Installing or upgrading to v2 C# SDKs

> [!WARNING]
> **Important**: This is not the [latest version](/v1/docs/installing-or-upgrading-to-the-v3-c-sharp-sdk). v2 SDKs are supported for now, but will be discontinued later in 2026.

You can install or upgrade to v2 of the following packages in .NET 8+ environments:

- LUSID C# SDK
- Other C# SDKs in the [FINBOURNE platform](/v1/docs/understanding-all-the-applications-in-the-finbourne-platform), for example Drive, Scheduler and Luminesce.

## Installing the v2 LUSID C# SDK

You can install v2 of the LUSID C# SDK using the following .NET command:

```shell
dotnet add package Lusid.Sdk
```

Note the following:

- .NET 8 or later is required.
- We strongly recommend pinning a SDK to an exact version to control when you take updates and make your builds repeatable.
- Alternatively, you can download the source by [cloning the Github repo](https://github.com/finbourne/lusid-sdk-csharp). If you do, note the `main` branch may not always correspond to the latest REST API version.

## Upgrading to v2 from an earlier version

You can upgrade from v1 to v2 of the LUSID C# SDK by using the following .NET command:

```shell
$ dotnet add package Lusid.Sdk
```

We recommend upgrading to this version as soon as possible to ensure you have access to the latest features.

Note that you must upgrade all SDKs used in a particular process to v2 at the same time. A process that uses both the Scheduler and Drive SDKs, for example, must either use v1 of both SDKs *or* v2 of both SDKs; mixing major versions will lead to dependency conflicts.

***Users need to update their code to reflect the following v2 changes...***

### Prerequisites for v2

.NET at version 8.0 or above.

### Preview SDKs

This release discontinues publishing the LUSID Preview SDK, instead adding the Experimental and Beta lifecycle APIs to a single SDK. The LUSID C# SDK now contains all the newest features; only `Lusid.Sdk` need be installed. Note that making requests to Experimental and Beta APIs requires additional licences; for more details please [contact support](https://www.finbourne.com/contact).

### Long-running API requests

Long-running API requests are enabled, giving users the option to extend or remove request timeout limits (previously timed out at 350 seconds). To extend the timeout on API calls, construct a configuration object and pass it into the `ApiFactory`, for example:

```csharp
var configuration = new Configuration
{
    BasePath = "https://<your-domain>.lusid.com/api",
    AccessToken = System.Environment.GetEnvironmentVariable("ACCESS_TOKEN"),
    Timeout = (int)TimeSpan.FromMinutes(10).TotalMilliseconds,
};
var client = new ApiFactory(configuration);
```

### Name changes

The following namespaces, classes and interfaces are renamed:

- `using Lusid.Sdk.Utilities` becomes `using Lusid.Sdk.Extensions`.
- `LusidApiFactory` becomes `ApiFactoryFactory`.
- `ILusidApiFactory` becomes `IApiFactory`.

`Version` becomes a reserved word in OpenApi Generator**:**

- `Sdk.Version` becomes `Sdk.ModelVersion`.
- Any model that implemented an `Sdk.Version` (now `Sdk.ModelVersion`) changes from `Version` to `_Version`.

## Upgrading to v2.2+ of the LUSID C# SDK

You can upgrade to v2.2+ of the LUSID C# SDK by running the following .NET command, but note the upgrade includes breaking changes due to the [removal of the RestSharp dependency](/v1/docs/installing-or-upgrading-the-lusid-c-sdk#removal-of-restsharp-dependency):

```shell
$ dotnet add package Lusid.Sdk
```

> [!WARNING]
> Important
> 
> If you are not ready to update to v2.2+, you can run the following .NET command to pin the SDK to the previous minor version (where `x` and `y` correspond to the minor and patch versions of the SDK you’re currently using):
> 
> ```shell
> $ dotnet add package Lusid.Sdk --version "[2.x.y,2.2)"
> ```

[See the respective GitHub repositories for upgrade commands for other C# SDKs in the FINBOURNE platform.](/v1/docs/understanding-all-the-applications-in-the-finbourne-platform)

### Removal of RestSharp dependency

Version 2.2+ of the C# SDKs includes the removal of the RestSharp dependency. Methods which previously used RestSharp types have been changed to use an equivalent type in the SDK and renamed. They may also contain fewer properties or have properties with different names.

When upgrading to v2.2+, you must check for breaking changes by compiling the code. You must update any code that directly references types from the RestSharp package.

You may need to update your code:

- If using `CreateHttpMessageHandler` or `createRestClientFunc` optional arguments in an `ApiClient` constructor.
- When defining or referencing static retry configuration on `RetryConfiguration` or `PollyApiRetryHandler`.
- In any references to the following properties which have been removed - these will fail to compile:
  - `Cookies` property of `IApiResponse` and `ApiResponse`
  - `CookieContainer` property of `RestClientOptions`

You can expand the following to see examples of how your code may need to change with v2.2+:

#### `CreateHttpMessageHandler` example

The following code references the `CookieContainer` property of `RestClientOptions` from the RestSharp package. v2.2 replaces this with `ClientOptions`, for which the `CookieContainer` property does not exist:

```csharp
// v2.1x and below of LUSID C# SDK:

var apiClient = new ApiClient(url, CreateHttpMessageHandler: options =>
{
    var handler = new HttpClientHandler();
    handler.Proxy = options.Proxy;
    handler.CookieContainer = options.CookieContainer;
    return handler;
});

// Becomes the following in v2.2 and above of the LUSID C# SDK:

var apiClient = new ApiClient(url, CreateHttpMessageHandler: options =>
{
    var handler = new HttpClientHandler();
    handler.Proxy = options.Proxy;
    return handler;
});
```

#### `createRestClientFunc` example

The following references the types `IRestClientWrapper`, `RestRequest` and `RestResponse`.

- `RestRequest` and `RestResponse` are types which come from the RestSharp package and have been replaced with `Request` and `Response` in the v2.2+.
- `IRestClientWrapper` has been renamed to `IClient` and its methods have changed. `RestResponse&lt;T&gt; WrappedExecute&lt;T&gt;(RestRequest request);` is now `Response&lt;T&gt; Execute&lt;T&gt;(Request request);`.

Note this optional parameter can be used when testing, as shown below, to stub out the server.

```csharp
// v2.1x and below of LUSID C# SDK:

using System.Net;
using Lusid.Sdk.Api;
using Lusid.Sdk.Client;
using Lusid.Sdk.Model;
using Moq;
using RestSharp;

namespace TestSdks;

public class BreakingChangesExamples
{
     [Test]
     public void CreateRestClientFuncExample()
     {
         var mockClient = new Mock<IRestClientWrapper>(MockBehavior.Strict);
         var url = "http://localhost:1234";
         var portfoliosToReturn = new ResourceListOfPortfolio(new List<Portfolio>
         {
             new Portfolio(
                 id: new ResourceId("my-scope", "my-code"),
                 displayName: "my-portfolio"
             )
         });
         var apiClient = new ApiClient(url, createRestClientFunc: (options, configuration) =>
         {
             mockClient.Setup(x => x.WrappedExecute<ResourceListOfPortfolio>(
                     It.Is<RestRequest>(request => request.Resource == "/api/portfolios")))
                 .Returns(new RestResponse<ResourceListOfPortfolio>(new RestRequest())
                 {
                     Data = portfoliosToReturn,
                     StatusCode = HttpStatusCode.OK,
                     ResponseStatus = ResponseStatus.Completed
                 });
             return mockClient.Object;
         });
         var apiInstance = new PortfoliosApi(apiClient, apiClient, new Configuration());
         var portfolios = apiInstance.ListPortfolios();
         Assert.That(portfolios.Values, Is.EquivalentTo(portfoliosToReturn.Values));
     }
}

// Becomes the following in v2.2 and above of the LUSID C# SDK:

using System.Net;
using Lusid.Sdk.Api;
using Lusid.Sdk.Client;
using Lusid.Sdk.Model;
using Moq;

namespace TestSdks;

public class BreakingChangesExamples
{
     [Test]
     public void CreateRestClientFuncExample()
     {
         // IRestClientWrapper has become IClient
         var mockClient = new Mock<IClient>(MockBehavior.Strict);
         var url = "http://localhost:1234";
         var portfoliosToReturn = new ResourceListOfPortfolio(new List<Portfolio>
         {
             new Portfolio(
                 id: new ResourceId("my-scope", "my-code"),
                 displayName: "my-portfolio"
             )
         });
         var apiClient = new ApiClient(url, createRestClientFunc: (options, configuration) =>
         {
             // WrappedExecute has become Execute
             mockClient.Setup(x => x.Execute<ResourceListOfPortfolio>(
                     // RestRequest has become Request
                     It.Is<Request>(request => request.Resource == "/api/portfolios")))
                 // RestResponse has become Response
                 .Returns(new Response<ResourceListOfPortfolio>(new Request())
                 {
                     Data = portfoliosToReturn,
                     StatusCode = HttpStatusCode.OK,
                     ResponseStatus = ResponseStatus.Completed
                 });
             return mockClient.Object;
         });
         var apiInstance = new PortfoliosApi(apiClient, apiClient, new Configuration());
         var portfolios = apiInstance.ListPortfolios();
         Assert.That(portfolios.Values, Is.EquivalentTo(portfoliosToReturn.Values));
     }
}
```

#### `RetryConfiguration` example

The following code defines the retry policy on the static class `RetryConfiguration`. It references `RestResponse` which comes from the RestSharp package. In v2.2+, `HandleResult` takes the type `ResponseBase` instead of `RestResponse`.

```csharp
// v2.1x and below of LUSID C# SDK:

RetryConfiguration.RetryPolicy = Policy
    .HandleResult<RestResponse>(response => response is
    {
        StatusCode: HttpStatusCode.BadGateway,
        ResponseStatus: ResponseStatus.TimedOut
    })
    .Retry();

// Becomes the following in v2.2 and above of the LUSID C# SDK:

RetryConfiguration.RetryPolicy = Policy
    .HandleResult<ResponseBase>(response => response is
    {
        StatusCode: HttpStatusCode.BadGateway,
        ResponseStatus: ResponseStatus.TimedOut
    })
    .Retry();
```

#### `PollyApiRetryHandler` example

The following code calls a method from the static class `PollyApiRetryHandler` which takes a parameter of type `RestResponse`. In v2.2+, `RestResponse` is replaced with `Response&lt;T&gt;`.

```csharp
// v2.1x and below of LUSID C# SDK:

var willRetry = PollyApiRetryHandler.GetPollyRetryCondition(new RestResponse
{
    StatusCode = HttpStatusCode.TooManyRequests
});

// Becomes the following in v2.2 and above of the LUSID C# SDK:

var willRetry = PollyApiRetryHandler.GetPollyRetryCondition(new Response<object>
{
    StatusCode = HttpStatusCode.TooManyRequests
});
```

> [!NOTE]
> **Note**: With v2.2+, it’s no longer necessary to import the RestSharp package. This version of the SDK also removes cookie handling.

### New `Finbourne.Sdk.Core` package

In v2.2, SDKs also reference the new package [Finbourne.Sdk.Core](https://www.nuget.org/packages/Finbourne.Sdk.Core). It is not necessary to reference this package directly but you should verify that your build processes do not block it, for example if you allow-list specified package downloads.

> [!NOTE]
> **Note**: The behaviour of the SDK is largely unchanged; although the RestSharp *package* dependency is removed, the RestSharp *client* is still in use. `Finbourne.Sdk.Core` encapsulates a version of RestSharp forked from the v112.0.0 release.

## Upgrading to v2.3+ of the LUSID C# SDK and .NET 8

If you upgrade to .NET 8+ and also to v2.3+ of the LUSID C# SDK, you must change the way in which [.NET reserved words](https://openapi-generator.tech/docs/generators/csharp-functions/#reserved-words) are handled.

> [!NOTE]
> **Note**: If you upgrade to .NET 8+ but keep using v2.2.x or earlier of the LUSID C# SDK, you do not need to do anything.

In v2.2.x or earlier, prefix .NET reserved words with `_` (an underscore) to avoid conflict, for example:

```csharp
public void CreateAborConfigurationExampleBefore() 
{ 
   var aborConfigResponse = CreateAborConfiguration(scope, aborConfigRequest); 
   aborConfigResponse._Version.AsAtVersionNumber; 
}
```

In v2.3+, prefix .NET reserved words with `var` instead, for example:

```csharp
public void CreateAborConfigurationExampleAfter() 
{ 
   var aborConfigResponse = CreateAborConfiguration(scope, aborConfigRequest); 
   aborConfigResponse.varVersion.AsAtVersionNumber; 
}
```

## Installing v1 of the LUSID C# SDK

Please note v1 of `Lusid.Sdk` and `Lusid.Sdk.Preview` is now discontinued, but if you *do* need to install it then two packages are published:

If you do need to install v1 of the LUSID C# SDK for any reason, note two packages are published:

- `Lusid.Sdk` contains only APIs with a [lifecycle status](/v1/docs/what-is-the-lusid-feature-release-lifecycle) of Production or Early Access. You can install the LUSID C# SDK using the following .NET command:

```shell
$ dotnet add package Lusid.Sdk --version "[1.*,2.0)"
```
- `Lusid.Sdk.Preview` contains additional APIs with a lifecycle status of Experimental or Beta. You can install the LUSID C# Preview SDK using the following .NET command:

```shell
$ dotnet add package Lusid.Sdk.Preview --version "[1.*,2.0)"
```
