We are using Unity for the dependency injection overriding the default behavior for the sitecore project. While deploying the jss app, I am getting below error:

The current type, Sitecore.JavaScriptServices.AppServices.Pipelines.Import.IImportPipeline, is an interface and cannot be constructed. Are you missing a type mapping?

when I try to resolve the dependency by registering the types by using below code, it leads to other errors which I am not sure is the right approach or not.

How can I resolve the dependencies for types used in Sitecore assemblies for successful deploying the app using Unity dependency injection?

            WithName.Default, WithLifetime.PerResolve, null, true);

Thanks, Hashmat

1 Answer 1


First off why are you using Unity? If this is a new build I would look at taking advantage of the inbuilt container that Sitecore uses; if you want a more feature rich container checkout SimpleInjector or one of the other DI containers in the .NET echo system.

If in fact, you do need to use Unity, consider resolving the Sitecore dependencies you need from the Sitecore container with a focused adaptor rather than re-registering them, this has the advantage of not having to understand how Sitecore builds up its dependency graph.

I like the idea of an application container where you have dependencies registered for your application and call out to the Sitecore container when required to get Sitecore Dependencies. If you want some more thoughts and motivations behind this suggestion have a read of this blog article I published on the topic.

  • The other major issue with taking over the whole IoC container like this is that you are making any future Sitecore upgrades much more difficult than they should be. If you really must use Unity, use an adaptor like mentioned above, or use your own parallel IoC infrastructure and leave Sitecore's alone.
    – Kam Figy
    Mar 5, 2019 at 20:30
  • 100% agree with Kam, there is also the question of whether you will be supported when messing with the Sitecore IoC container, this is a very grey area in my mind so I try to avoid it.
    – Gravypower
    Mar 5, 2019 at 22:06

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.