Sitecore 9.0.X Dependency Injection does not use latest Microsoft DI

With all of the excitement with Sitecore 9.X, sometimes it is very tempting to fire up a new project, get the latest NuGet packages and off you go, but there are a few subtle things to remember that Sitecore is embracing rather more niche dependencies and having embracing Microsoft.Extensions.DependencyInjection library from Microsoft is also one of them.

With Sitecore 9.0.X (pre 9.1), Sitecore Dependency Injection mechanism is dependent on on Microsoft.Extensions.DependencyInjection version 1.X.  If you are happen to add NuGet Package with version >2.X then you will get the following awesome message when deploying to the instance:

Method not found: ‘System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)’…

Please beware, to keep the version of dependencies strictly to what is provided by the version of the platform. Review carefully.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s