I have trouble with the latest version (7.7.6) of Umbraco and using Unity. If I have Unity enabled I get the following error in the Umbraco backend:
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Umbraco.Web.Editors.SectionController.GetSections()
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
If I disable Unity the backend works as expected. The Unity implementation worked fine in Umbraco v. 7.2.2 and earlier. I have followed the guideline at https://our.umbraco.org/Documentation/reference/using-ioc but I can't get the backend to work.
Any ideas of how to get things working? My Unity configuration looks like this right now. I've experimented with different techniques for loading all classes in different assemblies but without result.
public static void RegisterTypes(IUnityContainer container) {
container.RegisterType<UmbracoContext>(
new PerHttpRequestLifeTime(),
new InjectionFactory(c => UmbracoContext.Current)
);
//container.RegisterTypes(AllClasses.FromLoadedAssemblies());
//container.RegisterTypes(AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()));
container.RegisterType<LegacyTreeController>(new InjectionConstructor());
container.RegisterType<ISettingsProvider, UmbracoSettingsProvider>(new PerHttpRequestLifeTime());
}
I am getting similar issue am using ninject. What is the issue that the code you posted is solving? What is stopping the trees from loading? I can then put ninject equivalent.
I think it's really IoC specific, so not sure if ninject and unity will be equivalent on this... But has to do with the selection of the ctor (if you have both a parameterless ctor and a ctor with one or more parameters) and somehow we need to tell Unity to use a specific ctor (if there's multiple ctor's). Don't know the internals (did more or less a trail and error) but think you need to tell Unity to use the parameterless ctor if possible
Help! Unity and Umbraco 7.7.x
Hi
I have trouble with the latest version (7.7.6) of Umbraco and using Unity. If I have Unity enabled I get the following error in the Umbraco backend:
If I disable Unity the backend works as expected. The Unity implementation worked fine in Umbraco v. 7.2.2 and earlier. I have followed the guideline at https://our.umbraco.org/Documentation/reference/using-ioc but I can't get the backend to work.
Any ideas of how to get things working? My Unity configuration looks like this right now. I've experimented with different techniques for loading all classes in different assemblies but without result.
I hope there is someone who can give me at least a hint on where to look next. I've tried to follow the code into https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/Editors/SectionController.cs but without deeper knowledge of Umbraco foundation I get stuck very fast.
/Henrik
fwiw, if still struggling to get this working, just found out what needs changing to get it working with unity
user section has changed quite a lot in v7.7.x, took me too much time to find out it's this specific part of the config that was failing
Thank you! This solved my issues!
Dirk,
I am getting similar issue am using ninject. What is the issue that the code you posted is solving? What is stopping the trees from loading? I can then put ninject equivalent.
Regards
Ismail
Ismail,
I think it's really IoC specific, so not sure if ninject and unity will be equivalent on this... But has to do with the selection of the ctor (if you have both a parameterless ctor and a ctor with one or more parameters) and somehow we need to tell Unity to use a specific ctor (if there's multiple ctor's). Don't know the internals (did more or less a trail and error) but think you need to tell Unity to use the parameterless ctor if possible
Dirk
is working on a reply...