dependency Injection doesn't work in TreeController for rendering the second level of nodes
Hi,
I'm trying to develop a extension for Umbraco.
I inject via dependency injection (Autofac) a service in the tree controller.
It works fine until I go to the second level. Umbraco will create an instance from RaceTreeController by using the default constructor…
Error message:
Received an error from the server
Failed to retrieve data for child nodes undefined
Type 'Indegrade.Autoface.BackOffice.Controllers.RaceTreeController' does not have a default constructor
EXCEPTION DETAILS:
System.ArgumentException: Type 'Indegrade.Autoface.BackOffice.Controllers.RaceTreeController' does not have a default constructor
STACKTRACE:
at System.Linq.Expressions.Expression.New(Type type)
at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType)
at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator)
at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
I tested it with Autofac 3.5.2 (Autofac.MVC4 3.1.0 and Autofac.WebApi 3.1.0) and create another repo. The result is the same. As soon as I try to go to the second level I get the error.
dependency Injection doesn't work in TreeController for rendering the second level of nodes
Hi,
I'm trying to develop a extension for Umbraco. I inject via dependency injection (Autofac) a service in the tree controller.
It works fine until I go to the second level. Umbraco will create an instance from RaceTreeController by using the default constructor…
Error message:
Autofac configuration
RaceTreeController
Demo
I put a little demo together. There is a Umbraco V7 site in the solution the credentials are as follows: Username: admin, Password: admin
https://bitbucket.org/stevoknievo/umbracoautofacetest
Our help would be greatly appreciated, Thanks Stefan
I tested it with Autofac 3.5.2 (Autofac.MVC4 3.1.0 and Autofac.WebApi 3.1.0) and create another repo. The result is the same. As soon as I try to go to the second level I get the error.
Is that a bug in Umbraco?
https://bitbucket.org/stevoknievo/umbracoautofac352
At the first test I reference to Autofac 3.1.0 (Autofac.MVC4 3.1.0 and Autofac.WebApi 3.1.0)
It's the same with Umbraco 7.3 beta
https://bitbucket.org/stevoknievo/umbraco7.3betaautofac352
I have no idea. I hope someone can help as I can't work it out.
Thanks in advance, Stefan
instead of the traditional constructor injection, I using the "DependencyResolver"
is working on a reply...