Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bouy 7 posts 27 karma points
    Apr 02, 2014 @ 01:13
    Bouy
    0

    Umb. 7.0.4 + Autofac = "Failed to retrieve data for application tree content"

    Hello,I have a class "DependecyConfig" which is called from Global.asax on OnApplicationStarting.

     DependecyConfig.cs

    public static IContainer RegisterDependencies(Assembly currentAssembly)
            {
              
                var builder = new ContainerBuilder();

                // Register the controllers.
                builder.RegisterControllers(currentAssembly);
                builder.RegisterApiControllers(currentAssembly);

                builder.RegisterFilterProvider();

                var container = builder.Build();

                DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
                GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
              
                return container;
            }

    So there is an error while parsing Umbraco Nodes

    Failed to retreive data for application tree content


    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Stack Trace:

    at Umbraco.Web.Trees.ApplicationTreeExtensions.TryLoadFromControllerTree(ApplicationTree appTree, String id, FormDataCollection formCollection, HttpControllerContext controllerContext)
    
       at Umbraco.Web.Trees.ApplicationTreeController.<GetRootForSingleAppTree>d__17.MoveNext()
    
    --- End of stack trace from previous location where exception was thrown ---
    
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
    
       at Umbraco.Web.Trees.ApplicationTreeController.<GetApplicationTrees>d__4.MoveNext()

     

     

  • Bouy 7 posts 27 karma points
    Apr 02, 2014 @ 01:14
    Bouy
    0

    I have sql 2008 r2 server. So i dont think this is MySQL.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Apr 02, 2014 @ 08:50
    Dave Woestenborghs
    0

    Can you have a look at the last post on this page : http://our.umbraco.org/forum/developers/api-questions/41794-Web-API-UmbracoApiController-does-not-use-DependencyResolver?p=1

    Maybe this code can help you out

     

    Dave

  • Tom Hall 4 posts 29 karma points
    Apr 16, 2014 @ 15:32
    Tom Hall
    0

    @Bouy - did you resolve the problem? 

    I've just run into the problem, I'm using Umbraco 7.1.1 with Autofac 3.3.1. I've followed the steps in this post (http://our.umbraco.org/forum/developers/api-questions/41794-Web-API-UmbracoApiController-does-not-use-DependencyResolver?p=1), but still the back office is throwing the same exception. 

     

  • Tom Hall 4 posts 29 karma points
    Apr 17, 2014 @ 02:21
    Tom Hall
    5

    Update:

    I've solved my problems with Umbraco 7.1.1 and Autofac 3.3.1. Here's what I did:

    1. Install-Package Autofac.Mvc4
    2. Install-Package Autofac.WebApi
    Then, initialize Autofac as follows:
            public static void Initialize()
            {
                var builder = new ContainerBuilder();
    
                // Register umbraco context, mvc controllers and api controllers
                builder.Register(c => UmbracoContext.Current).AsSelf();
                builder.RegisterControllers(Assembly.GetExecutingAssembly());
                builder.RegisterApiControllers(typeof(UmbracoApplication).Assembly);
    
                // Register application specific types 
                RegisterTypes(builder);
    
                var container = builder.Build();
                var resolver = new AutofacWebApiDependencyResolver(container);
                GlobalConfiguration.Configuration.DependencyResolver = resolver;
                DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            } 

     

    I hope that helps others solve this problem.

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Oct 20, 2016 @ 14:20
    Simon Dingley
    0

    Lifesaver - thanks! The key to resolving the issue for me was this line:

    builder.RegisterApiControllers(typeof(UmbracoApplication).Assembly);
    

    UmbracoCms 7.5.2 & Autofac.Mvc5 & Autofac.WebApi2

  • mark firth 32 posts 75 karma points
    Aug 03, 2014 @ 14:29
    mark firth
    0

    Helped me. Had the exact same error.

    Thanks Tom for posting the fix.

  • Bart Plasmeijer 5 posts 25 karma points
    Nov 01, 2014 @ 23:40
    Bart Plasmeijer
    0

    Same here!

    Thanks Tom.

  • alper 8 posts 55 karma points
    Feb 24, 2015 @ 09:58
  • Matt Cheale 8 posts 33 karma points
    Jan 05, 2016 @ 17:06
    Matt Cheale
    2

    This fixed my issue too, with the slight difference that my controllers are in a separate project. I added the following line to resolve this:

    builder.RegisterApiControllers(typeof(UmbracoContext).Assembly);
    
  • Nguyen Hien 52 posts 133 karma points
    Jan 17, 2016 @ 16:15
    Nguyen Hien
    0

    This is exactly I need

  • Matthew Hunt 13 posts 35 karma points
    Apr 03, 2017 @ 22:52
    Matthew Hunt
    0

    bit late to this party, but had this issue and fixed with

    builder.RegisterApiControllers(typeof(Umbraco.Forms.Web.Trees.FormTreeController).Assembly)
    
  • James Drever 118 posts 149 karma points
    May 23, 2017 @ 10:13
    James Drever
    1

    This also saved me! Thanks for posting Tom! Proves how many people a post can help out over the years!

Please Sign in or register to post replies

Write your reply to:

Draft