# ServiceCollectionExtensions Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.configuration.internal.servicecollectionextensions/)

## AddFromExisting(IServiceCollection, Type, Type) {#addfromexisting-this-microsoft-extensions-dependencyinjection-iservicecollection-b0bb8adb}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.configuration.internal.servicecollectionextensions/methods/addfromexisting-this-microsoft-extensions-dependencyinjection-iservicecollection-b0bb8adb/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Configuration/ServiceCollectionExtensions.cs#L32-L52)

```csharp
public static void AddFromExisting(this IServiceCollection services, Type service, Type implementation)
```

Registers an existing registration of `implementation` as a provider of service type `service`.

### Parameters

- `services` (`IServiceCollection`): The service collection.
- `service` (`Type`): The service type being provided.
- `implementation` (`Type`): The implementation of `service`.

## AddFromExisting(IServiceCollection) {#addfromexisting-2-this-microsoft-extensions-dependencyinjection-iservicecollecti-f77fbdc5}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.configuration.internal.servicecollectionextensions/methods/addfromexisting-2-this-microsoft-extensions-dependencyinjection-iservicecollecti-f77fbdc5/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Configuration/ServiceCollectionExtensions.cs#L21-L22)

```csharp
public static void AddFromExisting<TService, TImplementation>(this IServiceCollection services)
```

Registers an existing registration of `TImplementation` as a provider of service type `TService`.

### Parameters

- `services` (`IServiceCollection`): The service collection.

## TryAddFromExisting(IServiceCollection) {#tryaddfromexisting-2-this-microsoft-extensions-dependencyinjection-iservicecolle-12c420ee}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.configuration.internal.servicecollectionextensions/methods/tryaddfromexisting-2-this-microsoft-extensions-dependencyinjection-iservicecolle-12c420ee/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Configuration/ServiceCollectionExtensions.cs#L62-L66)

```csharp
public static void TryAddFromExisting<TService, TImplementation>(this IServiceCollection services)
```

Registers an existing registration of `TImplementation` as a provider of `TService` if there are no existing `TService` implementations.

### Parameters

- `services` (`IServiceCollection`): The service collection.
