question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NetCore 3.x getting Container at ConfigureServices

See original GitHub issue

Hi @ltines

in the help net-dependency-extension it states: “Alternatively you can create ConfigureServices method in Startup class that gets passed the IWindsorContainer” What do you mean by this. If i:

public void ConfigureServices(IServiceCollection services, IWindsorContainer container)
        {
            services.AddControllers();
        }

I get an exception: “The ConfigureServices method must either be parameterless or take only one parameter of type IServiceCollection.”

And the “ConfigureContainer” is called after “ConfigureServices”

Is there any way we can control the container? I.e. so e.g. we pass the container into UseWindsorContainerServiceProvider(), e.g.:

            Host.CreateDefaultBuilder(args).UseWindsorContainerServiceProvider(contariner)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ltinescommented, Jul 9, 2020

Hi @ltines

in the help net-dependency-extension it states: “Alternatively you can create ConfigureServices method in Startup class that gets passed the IWindsorContainer” What do you mean by this. If i:

public void ConfigureServices(IServiceCollection services, IWindsorContainer container)
        {
            services.AddControllers();
        }

I get an exception: “The ConfigureServices method must either be parameterless or take only one parameter of type IServiceCollection.”

And the “ConfigureContainer” is called after “ConfigureServices”

Is there any way we can control the container? I.e. so e.g. we pass the container into UseWindsorContainerServiceProvider(), e.g.:

            Host.CreateDefaultBuilder(args).UseWindsorContainerServiceProvider(contariner)

@generik0 That’s a typo - it should be ConfigureContainer(IWindsorContainer container)

1reaction
generik0commented, Jul 7, 2020

Hi again everyone

I have noticed that instead of the UseWindsorContainerServiceProvider is is possible to add the startup base on the Startup with a factory implementation. This might be good to add to md?

Also, gives even more reason to allow substitution of the factory and methods, instead of an extension?

public class Startup: StartupBase<IWindsorContainer>
    {
        public Startup(IConfiguration configuration) : base(new WindsorServiceProviderFactory())
        {
            Configuration = configuration;
        }
Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core 3.x - Access IoC Container
In ASP.NET Core 3.x, the usage of IoC containers like Autofac changed. Instead of returning some adapter instance in ConfigureServices , we have ......
Read more >
Dependency injection in ASP.NET Core
The container resolves the dependencies in the graph and returns the fully resolved service. The collective set of dependencies that must be ...
Read more >
Avoiding Startup service injection in ASP.NET Core 3
In this post I describe the changes to dependency injection in your Startup class when upgrading an ASP.NET Core 2.x app to .NET...
Read more >
Dependency Injection in ASP.NET Core
ASP.NET Core allows us to register our application services with IoC container, in the ConfigureServices method of the Startup class.
Read more >
ASP.NET Core — Autofac 7.0.0 documentation
NET Core introduces a conforming container mechanism via Microsoft. ... AutofacContainer { get; private set; } // ConfigureServices is where you register ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found