# Third party DI containers

To enable third party containers support it is necessary to bootstrap the Radical application using the generic host support. To enable generic host support:

* Add a reference to the `Microsoft.Extensions.Hosting` nuget package
* Change the app boostrapping code as follows:

```csharp
class App
{
   public App()
   {
      var host = new HostBuilder()
         .AddRadicalApplication<Presentation.MainView>()
         .Build();

      Startup += async (s, e) => 
      {
         await host.StartAsync();
      };

      Exit += async (s, e) =>
      {
         using (host)
         {
            await host?.StopAsync();
         }
      };
   }
}
```

Using the above code sample the application boostrapping process is now delegated to the generic host. To add support for a different IoC container, for example Autofac, do the following:

* Add a reference to the `Autofac.Extensions.DependencyInjection` nuget package
* Change the `HostBuilder` creation section to add Autofac support as follows:

```csharp
var host = new HostBuilder()
    .UseServiceProviderFactory(new AutofacServiceProviderFactory())
    .AddRadicalApplication<Presentation.MainView>()
    .Build();
```

Refer to the documentation of you container of choice to get an overview of the steps required to integrate with the generic host. A full sample is available in the documentation repository at <https://github.com/RadicalFx/documentation/tree/master/samples/ThirdPartyContainer>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.radicalframework.com/concepts/ioc/third-party.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
