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

Method not found Autofac.ContainerBuilder.Update(Autofac.IContainer) #76

Open
pippolino opened this issue Feb 7, 2021 · 2 comments
Open

Comments

@pippolino
Copy link

pippolino commented Feb 7, 2021

The method Autofac.ContainerBuilder.Update(Autofac.IContainer) has been removed from Autofac v5.0.0 with the message: "Containers should generally be considered immutable. Register all of your dependencies before building/resolving. If you need to change the contents of a container, you technically should rebuild the container. This method may be removed in a future major release."

// Update the root container with a service that can be used to build per tenant container!
ContainerBuilder updateBuilder = new ContainerBuilder();
var defaultServices = options.DefaultServices;
updateBuilder.RegisterInstance(new DelegateActionTenantContainerBuilder<TTenant>(defaultServices, adaptedContainer, configureTenant, containerEventsPublisher)).As<ITenantContainerBuilder<TTenant>>();
updateBuilder.Update(container); /**** HERE ****/

Is it possible to update the "Autofac" method in "ContainerBuilderOptionsExtensions" to be able to use newer versions of the Autofac library?

Thanks

@dazinator
Copy link
Owner

@pippolino thanks for getting in touch.

Yeah it's not great is it.
To be honest, I have gone in a different direction recently with child containers. I am not sure what this means for this project yet suffice to say it's on hold for the time being in terms of me putting in any more time.

However I will consider PR's so if this is something you want to invest time in, I will consider merging a change to fix your scenario, but I won't be actively working on this repo for a time.

I am hoping that in the future, I'll bake in Microsoft.Extensions.DepenedencyInjection's native service provider as the default service provider to use for Child Containers, and I'll remove Autofac and Structuremap support, but allow those to be plugged in using a new mechanism. Until I have done work in other places to enable this, this project is effectively on hold.

@dazinator
Copy link
Owner

dazinator commented Feb 8, 2021

FYI: The child container implementation using ms's (slightly tweaked) native service provider is something I have up and running over here: https://github.com/dazinator/Dazinator.Extensions.DependencyInjection and at some point I expect to plug this in to dotnettency after I have done more scenario testing.

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