Copied to clipboard

Flag this post as spam?

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


  • Ben 5 posts 120 karma points
    Aug 19, 2015 @ 06:58
    Ben
    1

    Object reference not set to an instance of an object

    We are using umbraco version 7.2.6 , we installed the component using the "Umbraco Package Repository" , but we always got an "Object reference not set to an instance of an object." in the GetApplicationTrees method. And the developer pane would not load anymore.

  • Ben 5 posts 120 karma points
    Aug 24, 2015 @ 06:25
    Ben
    103

    So we did some further investigation, we downloaded the package using Nuget into the solution, but still the same error. Then we found and interesting article on the Umbraco forum [article here][1] .It looks like the controllers were not registered.

    So we added this line of code to the ApplicationStarted event:

    builder.RegisterApiControllers(typeof(Diplo.TraceLogViewer.Controllers.TraceLogController).Assembly);
    

    And then the component worked like a charm.

    Thx for this nice addon to the Umbraco CMS.

  • James Jackson-South 489 posts 1747 karma points c-trib
    Mar 08, 2016 @ 07:02
    James Jackson-South
    0

    For anyone else wondering what builder is (the link is broken), It's an Autofac ContainerBuilder instance.

  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    Oct 08, 2018 @ 13:07
    Markus Johansson
    2

    I was using LightInject and had the same problem, this solved it

    LightInjectStartup.ContainerBuilding += (sender, args) => {
    args.Container.RegisterAssembly(typeof(Diplo.GodMode.Controllers.GodModeTreeController).Assembly)
     };
    

    EDIT:

    Or even better:

    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
    
    LightInjectStartup.ContainerBuilding += (sender, args) =>
    {
    args.Container.RegisterControllers(assemblies);
    args.Container.RegisterApiControllers(assemblies);
    };
    
Please Sign in or register to post replies

Write your reply to:

Draft