3

I'm using ASP.NET Core's builtin DI container. It's missing some features I need, so I need to use a third-party container.

The top ones on Nuget are Autofac and StructureMap. SimpleInjector is consistently the fastest, so I'm considering it too.

I have a large code base, so I want to integrate an external container with minimal disruption and refactoring.

Are any of them drop-in replacements for the builtin container?

I'm not asking a subjective, "which is the best" sort of question. I don't really care. I need to know which is the most compatible.

asked Mar 10, 2017 at 14:13
2
  • Yeah this is actually quite complicated, there's no real consensus on the matter. But in theory, most containers work as drop-in replacements. Commented Mar 10, 2017 at 16:56
  • Although almost a decade later :-) ... would you mind mentioning some of such features ASP.NET Core's shipped DI container is/was missing that you had to resort to 3rd party libraries ? Commented Mar 3 at 13:19

2 Answers 2

2

According to this blog post, all that is required for ASP.NET Core to support your chosen DI container is to implement the IServiceProvider interface, using a wrapper around your DI container of choice. You're then free to use whatever additional features your container provides.

answered Mar 10, 2017 at 16:14
0

I've integrated Autofac into my system, and other than the few lines of config, it works as a drop-in replacement.

Other containers probably work too, but I can only confirm for Autofac.

answered Mar 10, 2017 at 17:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.