Installing Articulate Causes A NullReferenceException In Umbraco Backend

After installing Articulate on a new project, when I tried to load the 'Settings' section within the Umbraco back-end I start getting this error:

Exception Details
System.NullReferenceException: Object reference not set to an instance of an object.
Stacktrace
at System.Object.GetType()
   at Umbraco.Web.Trees.ApplicationTreeExtensions.<TryGetRootNodeFromControllerTree>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

After a lot of head scratching, uninstalling plug-ins and e=installing I was able to figure out the issue was a dependency injection issue.  Within my project, I was using Autofaq and the Articulate assembly needs to be registered within the DI set-up code, otherwise, it errors.

 

To register articulate with Autofaq within your DI set-up, you will need to add some code similar to the snippet below:

            var assembliesToRegister = new[]
            {
                typeof(ApplicationEventHandler).Assembly,
                typeof(ArticulateArchiveController).Assembly
            };

           var builder = new ContainerBuilder();
           builder.Register(c => UmbracoContext.Current).AsSelf();

            foreach (var assembly in assemblies)
            {
                builder.RegisterControllers(assembly);
                builder.RegisterApiControllers(assembly);
                builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();
            }

After registering Articulate with the RegisterApiControllers, when you rebuild your solution, the error should go away.

 

submit to reddit

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top