# OrleansClientGenericHostExtensions Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/)

## AddOrleansClient(IServiceCollection, Action&lt;IClientBuilder&gt;) {#addorleansclient-this-microsoft-extensions-dependencyinjection-iservicecollectio-6d7878cf}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/methods/addorleansclient-this-microsoft-extensions-dependencyinjection-iservicecollectio-6d7878cf/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Hosting/OrleansClientGenericHostExtensions.cs#L160-L164)

```csharp
public static IServiceCollection AddOrleansClient(this IServiceCollection services, Action<IClientBuilder> configureDelegate)
```

Configures the service collection to host an Orleans client.

### Parameters

- `services` (`IServiceCollection`): The service collection.
- `configureDelegate` (`Action<IClientBuilder>`): The delegate used to configure the client.

### Returns

The service collection.

### Exceptions

- `System.ArgumentNullException`: `services` was null or `configureDelegate` was null.

## AddOrleansClient(IServiceCollection, IConfiguration, Action&lt;IClientBuilder&gt;) {#addorleansclient-this-microsoft-extensions-dependencyinjection-iservicecollectio-17f71f18}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/methods/addorleansclient-this-microsoft-extensions-dependencyinjection-iservicecollectio-17f71f18/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Hosting/OrleansClientGenericHostExtensions.cs#L182-L186)

```csharp
public static IServiceCollection AddOrleansClient(this IServiceCollection services, IConfiguration configuration, Action<IClientBuilder> configureDelegate)
```

Configures the service collection to host an Orleans client.

### Parameters

- `services` (`IServiceCollection`): The service collection.
- `configuration` (`IConfiguration`): The configuration.
- `configureDelegate` (`Action<IClientBuilder>`): The delegate used to configure the client.

### Returns

The service collection.

### Exceptions

- `System.ArgumentNullException`: `services` was null or `configureDelegate` was null.

## UseOrleansClient(HostApplicationBuilder) {#useorleansclient-this-microsoft-extensions-hosting-hostapplicationbuilder-ecc7bce1}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/methods/useorleansclient-this-microsoft-extensions-hosting-hostapplicationbuilder-ecc7bce1/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Hosting/OrleansClientGenericHostExtensions.cs)

```csharp
public static HostApplicationBuilder UseOrleansClient(this HostApplicationBuilder hostAppBuilder)
```

Configures the host app builder to host an Orleans client.

### Parameters

- `hostAppBuilder` (`HostApplicationBuilder`): The host app builder.

### Returns

The host builder.

### Exceptions

- `System.ArgumentNullException`: `hostAppBuilder` was null.

## UseOrleansClient(HostApplicationBuilder, Action&lt;IClientBuilder&gt;) {#useorleansclient-this-microsoft-extensions-hosting-hostapplicationbuilder-system-bcd75c2f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/methods/useorleansclient-this-microsoft-extensions-hosting-hostapplicationbuilder-system-bcd75c2f/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Hosting/OrleansClientGenericHostExtensions.cs)

```csharp
public static HostApplicationBuilder UseOrleansClient(this HostApplicationBuilder hostAppBuilder, Action<IClientBuilder> configureDelegate)
```

Configures the host app builder to host an Orleans client.

### Parameters

- `hostAppBuilder` (`HostApplicationBuilder`): The host app builder.
- `configureDelegate` (`Action<IClientBuilder>`): The delegate used to configure the client.

### Returns

The host builder.

### Exceptions

- `System.ArgumentNullException`: `hostAppBuilder` was null or `configureDelegate` was null.

## UseOrleansClient(IHostApplicationBuilder) {#useorleansclient-this-microsoft-extensions-hosting-ihostapplicationbuilder-6b8ee651}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/methods/useorleansclient-this-microsoft-extensions-hosting-ihostapplicationbuilder-6b8ee651/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Hosting/OrleansClientGenericHostExtensions.cs)

```csharp
public static IHostApplicationBuilder UseOrleansClient(this IHostApplicationBuilder hostAppBuilder)
```

### Parameters

- `hostAppBuilder` (`IHostApplicationBuilder`): The host app builder.

### Returns

The host builder.

### Exceptions

- `System.ArgumentNullException`: `hostAppBuilder` was null.

## UseOrleansClient(IHostApplicationBuilder, Action&lt;IClientBuilder&gt;) {#useorleansclient-this-microsoft-extensions-hosting-ihostapplicationbuilder-syste-d1df0fbf}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/methods/useorleansclient-this-microsoft-extensions-hosting-ihostapplicationbuilder-syste-d1df0fbf/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Hosting/OrleansClientGenericHostExtensions.cs)

```csharp
public static IHostApplicationBuilder UseOrleansClient(this IHostApplicationBuilder hostAppBuilder, Action<IClientBuilder> configureDelegate)
```

Configures the host app builder to host an Orleans client.

### Parameters

- `hostAppBuilder` (`IHostApplicationBuilder`): The host app builder.
- `configureDelegate` (`Action<IClientBuilder>`): The delegate used to configure the client.

### Returns

The host builder.

### Exceptions

- `System.ArgumentNullException`: `hostAppBuilder` was null or `configureDelegate` was null.

## UseOrleansClient(IHostBuilder) {#useorleansclient-this-microsoft-extensions-hosting-ihostbuilder-00ebc272}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/methods/useorleansclient-this-microsoft-extensions-hosting-ihostbuilder-00ebc272/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Hosting/OrleansClientGenericHostExtensions.cs#L102)

```csharp
public static IHostBuilder UseOrleansClient(this IHostBuilder hostBuilder)
```

Configures the host builder to host an Orleans client.

### Parameters

- `hostBuilder` (`IHostBuilder`): The host builder.

### Returns

The host builder.

### Exceptions

- `System.ArgumentNullException`: `hostBuilder` was null.

## UseOrleansClient(IHostBuilder, Action&lt;HostBuilderContext, IClientBuilder&gt;) {#useorleansclient-this-microsoft-extensions-hosting-ihostbuilder-system-action-mi-63bab8e0}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/methods/useorleansclient-this-microsoft-extensions-hosting-ihostbuilder-system-action-mi-63bab8e0/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Hosting/OrleansClientGenericHostExtensions.cs)

```csharp
public static IHostBuilder UseOrleansClient(this IHostBuilder hostBuilder, Action<HostBuilderContext, IClientBuilder> configureDelegate)
```

Configures the host builder to host an Orleans client.

### Parameters

- `hostBuilder` (`IHostBuilder`): The host builder.
- `configureDelegate` (`Action<HostBuilderContext, IClientBuilder>`): The delegate used to configure the client.

### Returns

The host builder.

### Exceptions

- `System.ArgumentNullException`: `hostBuilder` was null or `configureDelegate` was null.

## UseOrleansClient(IHostBuilder, Action&lt;IClientBuilder&gt;) {#useorleansclient-this-microsoft-extensions-hosting-ihostbuilder-system-action-or-a52bda24}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/microsoft.extensions.hosting.orleansclientgenerichostextensions/methods/useorleansclient-this-microsoft-extensions-hosting-ihostbuilder-system-action-or-a52bda24/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Hosting/OrleansClientGenericHostExtensions.cs)

```csharp
public static IHostBuilder UseOrleansClient(this IHostBuilder hostBuilder, Action<IClientBuilder> configureDelegate)
```

Configures the host builder to host an Orleans client.

### Parameters

- `hostBuilder` (`IHostBuilder`): The host builder.
- `configureDelegate` (`Action<IClientBuilder>`): The delegate used to configure the client.

### Returns

The host builder.

### Exceptions

- `System.ArgumentNullException`: `hostBuilder` was null or `configureDelegate` was null.
