Questions tagged [dependency-injection]
Anything related to the use of Dependency Injection (DI)/IoC containers on a Sitecore solution. This also includes the baked-in Microsoft Dependency Resolver included natively in Sitecore versions 8.2 and above.
66 questions
1
vote
0
answers
48
views
Error in Personalize / Experience component computed index field
I am testing an upgraded site (9.0.2 to 10.3.1). I see the following new errors in the Sitecore logs when republishing the 10.3.1 site:
36148 14:13:02 ERROR [Content Testing]: Error in Experience ...
0
votes
1
answer
35
views
Invoke Sitecore service provider from SPE console
Is it possible to interact with Sitecore's DI container from the SPE command line? I was able to do this:
PS master:\>[Sitecore.DependencyInjection.ServiceLocator]::IsConfigured
True
But when I ...
1
vote
2
answers
262
views
Autofac DI with Sitecore 10.3
We are currently doing sitecore upgrade and but there are something broken with autofac DI integration with sitecore. we created our own serviceProviderBuilder which extends Sitecore....
1
vote
2
answers
855
views
IServicesConfigurator not found
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....
1
vote
0
answers
4k
views
An error occurred when trying to create a controller of type 'MapController'. Make sure that the controller has a parameterless public constructor
I'm working on an upgrade from Sitecore 8.2 to 10.1, and I've got some API Controllers. These worked in the 8.2 site but I'm encountering dependency injection issues now, getting the following error ...
2
votes
1
answer
485
views
Inject parameters and an object into pipeline processor using DI
How do I pass a parameter to the processor's constructor AND resolve its dependencies?
In the config I have:
<processor type="Feature.ErrorHandling.Pipeline.HttpRequest.PageNotFoundProcessor, ...
1
vote
1
answer
91
views
Error processing robots.txt
I occasionally see the below error in my logs
Error processing robots.txt
Exception: Glass.Mapper.MapperExceptioMessage: Service has been disposed, cannot create object
My code in Robotservice is as ...
0
votes
0
answers
136
views
Dependency Injection - Get current Language
I am trying to make full use of Dependency Injection with Sitecore 9.3. The hardest part is getting away from using Sitecore.Context. I've been looking at ShowServicesConfig.aspx to try and find what ...
2
votes
1
answer
309
views
Replace the default Sitecore IoC container with StructureMap in Sitecore 9.2
I built my own serviceProviderBuilder using StructureMap and replaced the default one from Sitecore.
public class StructureMapServiceProviderBuilder : BaseServiceProviderBuilder
{
protected ...
3
votes
1
answer
617
views
Custom submit action with constructor not working
I implemented a custom submit action and it works fine. But now I'm trying to store data to an external database using repository classes. For some reason it doesn't work if I add other interfaces in ...
0
votes
0
answers
555
views
Error when trying to Create a new form using Sitecore 9
On clicking Create new in Sitecore Form getting the below error:
Message: /formbuilder/load?id=&sc_formmode=new&sc_formlang=en&sc_site=shell&_=1597294914778StackTrace: at Autofac....
2
votes
1
answer
238
views
Extend /sitecore/api/ssc/EXM/Message with additional data
I want to extend /sitecore/api/ssc/EXM/Message endpoint with additional data.
I added a new class
namespace Exm.Extended
{
[ServicesController("EXM.Message")]
public class ...
1
vote
0
answers
77
views
Error on dragging a form element when using Ninject
I am getting below error when I drag a form element on form designer. I think it is because of dependency injection. I am using ninject DI in my application. Looking for help how to handle ...
0
votes
1
answer
147
views
Migration Onto Sitecore's DI Framework Knocked Out All Sitecore Logging
We're currently on Sitecore 9.1 and recently migrated onto Sitecore's dependency injection framework in order to get Sitecore Forms to work correctly. The transition seemed to go smoothly, however now ...
0
votes
0
answers
2k
views
Autofac.Core.DependencyResolutionException Sitecore 9.2
I am getting below error in the logs, when I am overriding Sitecore Dependency Injection with Autofac DI. I am using Sitecore 9.2.
The main issue is with Create Actions on EXM & Forms.
Can ...
2
votes
1
answer
1k
views
Sitecore 9.2 Dependency Injection in ApiController
I have a standard .net ApiController with the following code:
public class LibraryApiController : ApiController
{
private readonly ILibraryAssetRepository _repository;
public ...
0
votes
1
answer
339
views
Using Dependency Injection with Generic class
I am using sitecore 9.3 and was trying to add configuration for dependency injection of the implemented repository as below:
<register
serviceType="projectname.IRepository[[projectname.models....
1
vote
0
answers
371
views
MVC Layout model is empty after Glass Mapper Upgrade
We recently upgraded from Sitecore 8.2.0 to Sitecore 9.2.0. Along with other packages, we also upgraded to the latest compatible version of Glass Mapper 5 for Sitecore 9.2.0.
We use Simple Injector ...
1
vote
1
answer
2k
views
Unable to resolve service for type 'System.Collections.Generic.IList`1[Client.Feature.Membership.Services.FacetUpdaters.IContactFacetUpdater]'
I'm trying to replicate the federated auth from habitat using the Facebook example, and parlay that into auth with Salesforce. I can't get around this dependency injection error though.
Starting with ...
1
vote
1
answer
582
views
Publishing service 404
XHR requests in my publishing service are returning 404 with messages that resource could not be found:
{
"Message": "No HTTP resource was found that matches the request URI 'http://...
0
votes
2
answers
271
views
How to inject a dependency into a Processor
My processor is defined as follows:
<processor type="MyProject.MyProcessor, MyProject" resolve="true" />
I have then defined my Configurator Class:
<sitecore>
<services>
...
0
votes
0
answers
234
views
Dependency injection container issue SXA
I've recently upgraded the Sitecore 8.2 solution to Sitecore 9.1 update 1 which works fine.
But I also have to convert the existing site to SXA site. So, I started by adding the fresh SXA site but ...
2
votes
0
answers
193
views
How to implement DI service configurator in Automation Engine service registration
I am seeking to inject a service with dependencies into a Marketing Automation Activity Type that will be instantiated by the Marketing Automation Engine.
I have successfully injected a basic service ...
1
vote
1
answer
269
views
Sitecore dependency injection leak - IDisposable transient services
I'm getting a System.OutOfMemoryException: Array dimensions exceeded supported range. in Microsoft.Extensions.DependencyInjection.ServiceProvider.CaptureDisposable
Which appears to be where the DI ...
2
votes
1
answer
3k
views
How to make use of Autofac in IServicesConfigurator
We have changed the Dependency Injector in our Sitecore 9.1 solution to use Autofac, following this description as well as receiving a support .dll from Sitecore support.
We register our types using ...
1
vote
2
answers
910
views
Custom Dependency Injection for Sitecore pipeline processor with Ninject
I've implemented a custom Resolver for my Controllers for Ninject which works fine, however this is not working for pipelines.
How can I create a custom dependency Injection for Sitecore pipelines?
...
0
votes
0
answers
425
views
Sitecore.Context.Item added to Dependency Injection not working when needed by secodary DI'ed class
I need to get the context item to create a "SearchContext" in my repository class using the following configurator :
public class DependencyInjectionConfigurator : IServicesConfigurator
{
public ...
1
vote
0
answers
742
views
Sitecore 9 Forms - SimpleInjector conflicting with FormBuilderController
Sitecore 9.0.1 (rev. 171219)
SimpleInjector v.4.3.0
Glass.Mapper v.4.5.0.4
Steps To Reproduce:
In the Sitecore dashboard I click on the Forms button
Click the Create button and select Blank Form
On ...
0
votes
1
answer
268
views
Resolving dependencies using Unity for deploying sitecore jss app
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....
2
votes
3
answers
474
views
How can I pass correct IProviderSearchContext context of my custom index to repository via Dependency Injection?
I have a custom index which has additional teaser title, teaser description, main title and main content fields and the index is resolved based on Sitecore.Context.Database. Eg. master database ...
1
vote
2
answers
2k
views
Could not create object from service provider - Registering service using Dependency Injection
I have created an ItemNotFoundResolver and injected it after ItemResolver pipeline as follows :
public class ItemNotFoundResolver : HttpRequestProcessor {
private readonly ISitecoreEntityService ...
3
votes
0
answers
367
views
How to inject dependencies in solution that extends Sitecore Reference Storefront
I patched the Initialize Pipeline InitializeControllerFactory processor to point to my new solution InitializeControllerProcessor via:
<?xml version="1.0"?>
<configuration xmlns:...
3
votes
2
answers
1k
views
Autofac in Sitecore 9
I have a clean installation of Sitecore 9.0.2 and am trying to hook up Autofac, however I am getting the following exception when trying to load any page on the site / CMS.
In the logs:
Exception: ...
2
votes
1
answer
522
views
Injecting dependencies into custom ServicesApiController without using ServiceLocator
I am injecting a dependency into a custom API controller I've created that is inheriting from ServicesApiController. I have found that I need to use our service locator class to do this as otherwise, ...
4
votes
1
answer
3k
views
Dependency Injection for Sitecore pipeline processor
We are using Castel windsor for DI in our Sitecore solution. Though we haven't done any IOC registration using Sitecore pipelines, It still resolves the Controllers. I'm fine with it. But the same is ...
10
votes
1
answer
420
views
Initialize service in pipeline to be available through one httprequest
We're using Sitecore 8.2, habitat.
I have a service that I need to use throughout a full HTTP Request. This service should be instantiated once (we use dependancy injection) and then be available ...
2
votes
2
answers
551
views
Is Pipeline Ref Factory still available?
As described in this article.
https://cardinalcore.co.uk/2014/07/02/sitecore-pipelines-commands-using-ioc-containers/
you can use pipeline "ref" and "factory" attributes, to use dependency injection ...
5
votes
1
answer
790
views
Getting an instance of BaseCorePipelineManager
In the Sitecore doc Configuring Federated Authentication there are instructions to generate the URL links to initiate Federated Auth -- the lines are:
using Sitecore.Pipelines.GetSignInUrlInfo;
/*
[.....
10
votes
2
answers
735
views
Dependency Injection Not Wiring Up Properly When Optimize Code is Selected in Build
Sitecore 8.2u5
Primary Question
Why does Optimizing Code cause Dependency Injection to fail?
We've used DI on many projects at this point and just had an issue with a recent one. The error ...
1
vote
2
answers
625
views
Sitecore Content Search Exception: Entry point was not found
I'm having an issue taking an older version of our site running under Sitecore 7.2 (with some older dll's such as glass mapper) and switching over from Lucene to Solr (6.6.2).
I've followed the steps ...
5
votes
0
answers
2k
views
Ninject activation exception on publish: ILogManager
I started getting a strange error on publish in one our our dev sitecore instances that seems to be coming from some Sitecore.Social.Client piplines.
Exception[1]: Ninject.ActivationException
...
1
vote
1
answer
630
views
Sitecore.DependencyInjection will not resolve
I'm trying to use dependency injection with the Helix project structure for a sitecore 8.1 project, but I'm having an issue resolving the correct dependencies.
The code has been copied from the Helix ...
1
vote
1
answer
803
views
Glass Mapper and Microsoft DI
I am using Microsoft DI with Sitecore 8.2 Update 3. I have registered my Glass Items like this:
serviceCollection.AddTransient<ISitecoreContext>(provider => new SitecoreContext());
...
9
votes
3
answers
1k
views
Sitecore 8.2 memory leak with autofac DI on load test
We implemented the Autofac to work with Sitecore default DI implementation by following the guide below:
https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/...
7
votes
4
answers
5k
views
How to register Glass Mapper ISitecoreService in my Ioc
Using GlassMapper 4, Sitecore 8.2 update 3 and Microsoft DI
How do I register the GlassMapper SitecoreService in my Ioc. It requires a Database and Im not entirely clear on how to get that inside my ...
6
votes
2
answers
718
views
IOC (Simple Injector) with EntityService
UPDATED WITH LATEST RESULTS AND QUESTION
I've converted everything to pipeline and integrated Simple Injector. As I mentioned, I've never used SI before, and I'm having trouble with the controller ...
4
votes
0
answers
259
views
After replacing default DI container Sitecore 8.2 Sitecore ItemService and EntityService stop working
Thanks to Dmytro Shevchenko
http://structuredcode.com/replacing-default-di-container-sitecore-8-2/
We are replacing default DI Container with Windsor Castle. All project works perfectly fine, except ...
10
votes
1
answer
2k
views
Recursive upgradeable lock acquisitions not allowed in this mode exception while accessing Sitecore configuration while initiating the IoC container
When trying to access the Sitecore Configuration Factory to read a setting while configuring services in the IoC container the below exception is thrown.
public class ServicesConfigurator : ...
1
vote
1
answer
146
views
Custom controller being overwritten by IoC
I have a simple Sitecore controller that returns an list of items from Sitecore. It's used it in a custom SPEAK UI page.
This works fine in my local dev environment but when I deploy it into an ...
8
votes
1
answer
2k
views
Castle Windsor on Sitecore 8.2 using Glass Mapper v4
I'm trying to setup Castle Windsor for Dependency Injection in Sitecore 8.2 Solution which is using Glass Mapper v4. As noted, Castle Windsor is no longer part of Glass Mapper, and thus not included. ...