Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the "Without ConfigureContainer" mechanism? #85

Closed
jimmcslim opened this issue Sep 25, 2019 · 3 comments
Closed

What is the "Without ConfigureContainer" mechanism? #85

jimmcslim opened this issue Sep 25, 2019 · 3 comments
Assignees

Comments

@jimmcslim
Copy link

The page https://github.com/autofac/Documentation/blob/master/docs/integration/aspnetcore.rst has a comment in a code example:

  // If you need a reference to the container, you need to use the
  // "Without ConfigureContainer" mechanism shown later.

However it is not clear if this is actually shown?

Also, is it possible to combine ConfigureContainer and AddControllersAsServices()... an example for that would be helpful as well.

@alsami
Copy link
Member

alsami commented Sep 25, 2019

Ups, something got lost there. Which version of ASP.NET-Core are you on?

Anyway, when below ASP.NET Core 3. You can do the following in your Startup.cs.

public IServiceProvider ConfigureServices(IServiceCollection services)
{
   // add stuff to services, like services.AddMvc();
   var containerBuilder = new ContainerBuilder();
   // add stuff to the containerBuilder
   containerBuilder.Populate(services);
   var container = container.Build();
   return new AutofacServiceProvider(container);
}

I will create a PR soon to fix that.

Also, is it possible to combine ConfigureContainer and AddControllersAsServices()... an example for that would be helpful as well.

What do you mean by that? Would you eloberate?

@alsami alsami self-assigned this Sep 25, 2019
alsami added a commit to alsami/Documentation that referenced this issue Sep 25, 2019
@jimmcslim
Copy link
Author

jimmcslim commented Sep 30, 2019

Actually I don't think I had a further problem, or whatever it was, I've forgotten it! Thanks!

@alsami
Copy link
Member

alsami commented Sep 30, 2019

Okay, then your question should be answered now. We have added a sample again on how to do it with ASPNET Core version < 3.0 and without configure container.

@alsami alsami closed this as completed Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants