Installing Umbraco Forms Causes The Umbraco Backend To Break

Recently I installed Umbraco forms (via NuGet) and immediately after installing it the backend broke... badly.  All the sections in my site vanished and nothing worked anymore, as seen below.  If you have a similar issue then read on as hopefully, this guide will save you some time.

First I checked the logs and error was being thrown

2018-10-25 18:33:19,551 [P54184/D10/T67] ERROR Umbraco.Web.Editors.SectionController - Unhandled controller exception occurred
System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Object.GetType()
   at Umbraco.Web.Trees.ApplicationTreeExtensions.<TryGetRootNodeFromControllerTree>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Umbraco.Web.Trees.ApplicationTreeController.<GetRootForMultipleAppTree>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Umbraco.Web.Trees.ApplicationTreeController.<GetApplicationTrees>d__0.MoveNext()
   --- End of inner exception stack trace ---
   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 you have this issue and you are using dependency injection/Autofaq, then you will need to register the Umbraco Forms assemblies with your DI container.  If you don't know where this is in your project I suggest you start looking in your Global.ascx

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(RazorEmailViewController).Assembly,
typeof(UmbracoFormsController).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 recompiling my project, my backend worked, hope this helps you, enjoy.

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