Object reference error after upgrading to K13

Danny Winbourne asked on November 24, 2021 17:23

I am currently upgrading a K12 MVC project to K13 MVC 5. I have successfully upgraded the CMS solution, and it's loading without error.

However, I am getting the following error when loading the MVC site.

[NullReferenceException: Object reference not set to an instance of an object.]
   Kentico.Content.Web.Mvc.Routing.PageUrlPathConstraint.Match(HttpContextBase httpContext, Route route, String parameterName, RouteValueDictionary values, RouteDirection routeDirection) +62
   System.Web.Routing.Route.ProcessConstraint(HttpContextBase httpContext, Object constraint, String parameterName, RouteValueDictionary values, RouteDirection routeDirection) +105
   Castle.Proxies.Invocations.Route_ProcessConstraint_1.InvokeMethodOnTarget() +286
   Castle.DynamicProxy.AbstractInvocation.Proceed() +105
   Glimpse.Core.Extensibility.ExecutionTimer.Time(Action action) +73
   Glimpse.Core.Extensions.AlternateMethodContextExtensions.TryProceedWithTimer(IAlternateMethodContext context, TimerResult& timerResult) +227
   Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext context) +31
   Castle.DynamicProxy.AbstractInvocation.Proceed() +451
   Castle.Proxies.RouteProxy_1.ProcessConstraint(HttpContextBase httpContext, Object constraint, String parameterName, RouteValueDictionary values, RouteDirection routeDirection) +349
   System.Web.Routing.Route.ProcessConstraints(HttpContextBase httpContext, RouteValueDictionary values, RouteDirection routeDirection) +234
   System.Web.Routing.Route.GetRouteData(HttpContextBase httpContext) +218
   Castle.Proxies.Invocations.Route_GetRouteData_1.InvokeMethodOnTarget() +88
   Castle.DynamicProxy.AbstractInvocation.Proceed() +105
   Glimpse.Core.Extensibility.ExecutionTimer.Time(Action action) +73
   Glimpse.Core.Extensions.AlternateMethodContextExtensions.TryProceedWithTimer(IAlternateMethodContext context, TimerResult& timerResult) +227
   Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext context) +31
   Castle.DynamicProxy.AbstractInvocation.Proceed() +451
   Castle.Proxies.RouteProxy_1.GetRouteData(HttpContextBase httpContext) +235
   System.Web.Routing.RouteCollection.GetRouteData(HttpContextBase httpContext) +269
   System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +67
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +222
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +219
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +93

The product does use custom routing, but I am not able to find where to add a breakpoint, as the error occurs before it hits any code.

It's possibly related to DocumentNamePath being removed from CMS_Document in this upgrade, as I think that the custom routing used this field, but I have made changes already for this (although possibly incorrectly). But it's not clear from the error what exactly has gone wrong.

Correct Answer

Danny Winbourne answered on November 25, 2021 14:53

I resolved my issue. I had included a reference to a Kentico library that should only have been included in the CMS. This caused a conflict during the application startup causing the duplicate entry to the route table described above.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Danny Winbourne answered on November 24, 2021 17:45

It's possible that the RouteTable is not being built correctly. I am seeing this error in the Event Viewer.

Message: The route template 'getavatar/{avatarguid:guid}/{filename}' is already registered.
Parameter name: descriptor

Exception type: System.ArgumentException
Stack trace:
at CMS.Base.Routing.HttpHandlerRouteTable.Register(RegisterHttpHandlerAttribute descriptor)
at CMS.Core.TypeManager.PreInitializeTypes(Assembly assembly)

Although I am not sure where this is coming from, and how to resolve it.

0 votesVote for this answer Mark as a Correct answer

Saul Sheehan answered on November 25, 2021 14:51 (last edited on November 30, 2021 12:07)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.