After upgrade Umbraco 7.15 to 8.5.5 (Autofac to LightInject dependencies are not working)
Hi,
I have upgraded Umbraco 7.15 to 8.5.5. After upgrade that Autofac dependencies was not working because .net framework does not support it. So I have tried LightInject, which is I think alternate of Autofac.
But LightInject not resolve all the dependencies same as Autofac. e.g.
public T Resolve<T>(string key = "", Scope scope = null) where T : class
{
if (scope == null) scope = Scope();
return string.IsNullOrEmpty(key) ? scope.GetInstance<T>() : scope.GetInstance<T>(key);
}
Please suggest me what I can do here to resolve this issue.
Thank for the reply.
I have already tried the example you have shared e.g.
var serviceContainer = composition.Concrete as LightInject.ServiceContainer;
serviceContainer.Register<IWorkContext, WorkContext>(new PerContainerLifetime());
It is not working.
There are some custom services used like below screenshot and throwing error:
This line is throwing error in the Resolve T function:
var workContext = IpfExtraNetEngineContext.Current.Resolve<IWorkContext>();
Resolve T is using in whole project and without resolving dynamic dependencies it will not work.
Please suggest if any way to fix it?
After upgrade Umbraco 7.15 to 8.5.5 (Autofac to LightInject dependencies are not working)
Hi,
I have upgraded Umbraco 7.15 to 8.5.5. After upgrade that Autofac dependencies was not working because .net framework does not support it. So I have tried LightInject, which is I think alternate of Autofac.
But LightInject not resolve all the dependencies same as Autofac. e.g.
Please suggest me what I can do here to resolve this issue.
Thanks.
Hi Shuchita
There is a good introduction to lightinject in V8 here:
https://our.umbraco.com/Documentation/Reference/Using-Ioc/
I think you need to do less than with autofac to wire things up.
Hopefully that might give you some insights in how to move from one DI framework to the other...
regards
marc
Hi Marc,
Thank for the reply. I have already tried the example you have shared e.g.
It is not working. There are some custom services used like below screenshot and throwing error: This line is throwing error in the Resolve T function:
Resolve T is using in whole project and without resolving dynamic dependencies it will not work. Please suggest if any way to fix it?
Thank you.
Hi Shuchita
Are you trying to service locate IWorkContext?
if so
might be what you need, if IWorkContext is registered as you have above with the DI container?
Or are you expecting all your dependencies to be autoscanned? if so there is an interesting long debate regarding that for V8 https://github.com/umbraco/Umbraco-CMS/issues/7502
regards
Marc
Hi Marc,
This is working at my end
Current.Factory.GetInstance<IWorkContext>()
Thank you so much.
Hi Shuchita, Please message me. I need your help developing Umbarco 12 site. parttime/fulltime rishi at osho net
is working on a reply...