Andrew
Andrew

Reputation: 933

ASP.NET Core with Simple Injector

I have created a ASP.NET Core Web API application from the VS templates (I have updated VS with the latest ASP.NET Core RC2). However, I am running into issues when attempting to set up my application to use SimpleInjector as the IoC container.

I am using the instructions provided here. When I have my mirroring the instructions found at that link, I get an error in the ConfigureServices method saying that IServiceCollection does not have a definition for AddInstance. It also says that IControllerActivator could not be found.

public void ConfigureServices(IServiceCollection services)
    {
        // Add framework services.
        services.AddMvc();

        services.AddInstance<IControllerActivator>(
        new SimpleInjectorControllerActivator(container));
        services.AddInstance<IViewComponentInvokerFactory>(
            new SimpleInjectorViewComponentInvokerFactory(container));
    }

I realize there may be issues as I'm using the newest RC2 release of ASP.NET (and SimpleInjector support for ASP.NET Core is beta), but I was curious if anyone knew a workaround. Thanks!

Upvotes: 1

Views: 6527

Answers (1)

Steven
Steven

Reputation: 172606

Making all the required parts of Simple Injector compatible with RC2 was quite some undertaking. Microsoft changed about everything (including API, MVC and tooling). So it took us a few days to fix this and create a compatible version.

But I'm happy to announce that v3.1.5 of Simple Injector is compatible with .NET Core 1.0.0-rc2 and version v3.1.5-rc2-02 of the SimpleInjector.Integration.AspNet package is compatible with RC2 as well. We updated the documentation as well.

Upvotes: 5

Related Questions