This is the first time i deal with custom validations, but I need to create a unique email validation using sitecore 9.0.2 and SXA 1.7.1 so i was following this tutorial


but i have a problem with this method:

protected virtual IFormDataProvider FormDataProvider
            IFormDataProvider formDataProvider = this._dataProvider;
            if (formDataProvider == null)
                IFormDataProvider service = ServiceLocator.ServiceProvider.GetService<IFormDataProvider>();
                IFormDataProvider formDataProvider1 = service;
                this._dataProvider = service;
                formDataProvider = formDataProvider1;
            return formDataProvider;

specifically this line:

IFormDataProvider service = ServiceLocator.ServiceProvider.GetService<IFormDataProvider>();

saying that:

'IServiceProvider' does not contain a definition for 'GetService' and the best extension method overload 'DependencyResolverExtensions.GetService(IDependencyResolver)' requires a receiver of type 'IDependencyResolver'

Any ideas what might be the cause ?

  • 1
    Do you have a reference to Microsoft.Extensions.DependencyInjection.Abstractions.dll?
    – Marek Musielak
    Feb 3, 2019 at 16:47
  • No , i didn't. i only had the Microsoft.Extensions.DependencyInjection not the abstractions. Thank you , that fixed it. Feb 4, 2019 at 8:54
  • Comment converted into an answer.
    – Marek Musielak
    Feb 4, 2019 at 9:13

2 Answers 2


You need to add a reference Microsoft.Extensions.DependencyInjection.Abstractions.dll to your project.

It's not enough to have Microsoft.Extensions.DependencyInjection.dll referenced only.


Add "using Microsoft.Extensions.DependencyInjection" to your usings should solve it. I had the same problem and VS didn't added it automatically.

  • i did have the reference to Microsoft.Extensions.DependencyInjection.dll and was using it but it was not working. Turns out i should use instead Microsoft.Extensions.DependencyInjection.Abstractions.dll reference like @Marek Musielak suggested and add the using like you suggested.Thank you for your help. Feb 4, 2019 at 8:58

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.