1

My Sitecore web application is a .Net Framework 4.8 Web application. I am trying to integrate Sitecore DI container. I have added Nuget packages for Microsoft.Extensions.DependencyInjection, Microsoft.Extensions.DependencyInjection.Abstraction and Sitecore.DependencyInjection.

I have written ServicesConfigurator class looking at example here. For some reason, IServicesConfigurator is not getting resolved. Please refer to the attached image.

Can anyone please help? Is it because I am using .Net Framework 4.8 Web application? I dont think so.

Thanks in advance.

enter image description here

2
  • close the VS and clean the temp file then open, and build the solution. Make sure dependency injection DLL is added to your project reference. and also update your build error in your question. Jan 11, 2023 at 4:21
  • @Rameshkumar this is the first thing I tried but didn't work. It got resolved after providing reference of Sitecore.Kernel Jan 11, 2023 at 8:56

2 Answers 2

1

It's working fine with.Net Framework 4.8 Web application. It's a reference issue with dlls/version of dll. I think You need to add a Nuget package reference of Sitecore.Kernel as per your Sitecore version into the project. IServicesConfigurator interface is a part of Sitecore.DependencyInjection namespace and part of Sitecore.Kernel.Dll.It would install relative dependencies of DI DLLs like below.

enter image description here

You can remove all the references you added and add Sitecore.Kernel from the Nuget package and create ServicesConfigurator class.

using Sitecore.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;

namespace XX.Website
{
    public class ServicesConfigurator : IServicesConfigurator
    {
        public void Configure(IServiceCollection serviceCollection)
        {
            //Code here
        }
    }
}
0

Sitecore.Kernel DLL reference is mandatory to make use of DLL Sitecore.DependencyInjection.

enter image description here

Make sure you have added a compatible reference of DLL Sitecore.Kernel.

I am using Sitecore DI with version V 10.2 and the DI is working as expected. The DLL version details are given below,

Microsoft.Extensions.DependencyInjection, Version=3.1.14.0

Sitecore.Kernel, Version=17.0.0.0

.Net Framework, Version=4.8

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.