Glass.Mapper
Glass.Mapper copied to clipboard
Documentation for Mixing in IoC containers in mvc website project with Sitecore 8.2 and latest glass mapper?
We are in the process of upgrading website (sitecore 7.2 + glass.mapper 4.0 + glass.mapper.castlewindsor) to sitecore 8.2 + glass.mapper 4.3. I understand that Glass.Mapper.Sc.CastleWindsor has been discontinued .but, I can only see 2013 article related to IoC integration but that seems outdated http://www.glass.lu/Blog/MixingInIoc. Is there any latest documentation to integrating IoC (WindsorSitecoreInstaller etc) ? Please advice. Thanks
Hi
Do you need to instantiate your models via Castle Windsor? If you don't need to instantiate your model via Castle Windsor then you can use the latest version of Glass.Mapper.Sc without needing to Mix in IOC.
You will need to update any Glass customisation registrations to register them with the new DI container used by Glass instead of Castle Windsor.
You can then continue to use Castle Windsor for the rest of your project and Glass will uses its own DI when needed.
Mike
Hi Mike,
For now, we are trying to use the Microsoft DI that Sitecore 8.2 uses internally. What is the new DI container used by glass and how can we register glass customizations in the future?
Hi Mike, sitecore 8.2 uses microsoft DI. we get below errors for SitecoreService object construction. Please suggest a fix. Thanks
public AWCNService(ISitecoreContext context, IAWCNSiteRepository repository, ISitecoreService sitecoreService, ISiteSearchService siteSearchService) { _sitecoreContext = context; _siteRepository = repository; _service = sitecoreService; _siteSearchService = siteSearchService; }
Exception: System.InvalidOperationException Message: Unable to resolve service for type 'Glass.Mapper.Sc.ISitecoreService' while attempting to activate 'UNWomen.SC.AWCN.Services.AWCNService'. Source: Microsoft.Extensions.DependencyInjection at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.PopulateCallSites(ServiceProvider provider, ISet
1 callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.CreateCallSite(ServiceProvider provider, ISet1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetResolveCallSite(IService service, ISet1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetServiceCallSite(Type serviceType, ISet1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.PopulateCallSites(ServiceProvider provider, ISet1 callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.CreateCallSite(ServiceProvider provider, ISet1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetResolveCallSite(IService service, ISet1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetServiceCallSite(Type serviceType, ISet1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType, ServiceProvider serviceProvider) at System.Collections.Concurrent.ConcurrentDictionaryExtensions.GetOrAdd[TKey,TValue,TArg](ConcurrentDictionary2 dictionary, TKey key, Func3 valueFactory, TArg arg) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Sitecore.Mvc.Controllers.SitecoreDependencyResolver.GetService(Type serviceType) at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
Verify that you have registered the the Glass.Mapper.Sc.SitecoreService as the implementation for Glass.Mapper.Sc.ISitecoreService in the Sitecore DI container.
Hi Mike, we are assuming that SitecoreContext and SitecoreService are the only ones. But this article seem to mention more - https://sitecore.stackexchange.com/questions/5883/how-to-register-glass-mapper-isitecoreservice-in-my-ioc . Are these classes not registered within glass mapper DI? Can you give details on how and what need to be registered for integration with sitecore 8 DI. Thank you.