Copied to clipboard

Flag this post as spam?

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

  • Brendan Rice 507 posts 942 karma points
    Sep 07, 2021 @ 10:46
    Brendan Rice

    Error with SurfaceControllers in 8.15.1

    After upgrading a recent site from 7.5.4 - 8.15.1 it went through staging then live.

    Once it hit live the following error intermittently appears:

    Unable to resolve type: MySurfaceController, service name: 

    Code is in the App_Code folder. I haven't seen this issue before, can anyone help please?

    MySurfaceController looks like this:

    public partial class MySurfaceController: Umbraco.Web.Mvc.SurfaceController
        public ActionResult Index(ContentModel model)

    Stack trace:

    [InvalidOperationException: Unable to resolve type: MySurfaceController, service name: ]
    LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError) in C:\projects\lightinject\src\LightInject\LightInject.cs:4754
    LightInject.ServiceContainer.CreateDefaultDelegate(Type serviceType, Boolean throwError) in C:\projects\lightinject\src\LightInject\LightInject.cs:4705
    LightInject.ServiceContainer.GetInstance(Type serviceType) in C:\projects\lightinject\src\LightInject\LightInject.cs:3437
    Umbraco.Web.Mvc.ContainerControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) in D:\a\1\s\src\Umbraco.Web\Mvc\ContainerControllerFactory.cs:21
    [Exception: Failed to create an instance of controller type TWB.Controllers.Surface.StoreFinderController (see inner exception).]
    Umbraco.Web.Mvc.ContainerControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) in D:\a\1\s\src\Umbraco.Web\Mvc\ContainerControllerFactory.cs:25
    Umbraco.Web.Mvc.UmbracoControllerFactory.CreateController(RequestContext requestContext, String controllerName) in D:\a\1\s\src\Umbraco.Web\Mvc\UmbracoControllerFactory.cs:38
    Umbraco.Web.Mvc.RenderControllerFactory.CreateController(RequestContext requestContext, String controllerName) in D:\a\1\s\src\Umbraco.Web\Mvc\RenderControllerFactory.cs:36
    System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +262
    System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +77
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +1122
    System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +131
  • Jamie Townsend 59 posts 279 karma points c-trib
    Sep 07, 2021 @ 22:53
    Jamie Townsend

    Hi Brendan,

    A couple of things, when you say upgrade what do you mean, if you've upgraded using nuget or something? You cannot upgrade from 7 to 8, at least not easily, nor recommended. You would need to start a new project and migrate content etc.

    It's been a while since I've used App_Code so I would recommend moving controllers into their own /controllers/ folder.

    It would help to know what you're doing with this Surface controller, especially as you're expecting, 'ContentModel' being passed in.

    Finally your error mentions MySurfaceController but your class is called StoreFinderController

    Good luck,


  • Brendan Rice 507 posts 942 karma points
    Sep 08, 2021 @ 17:07
    Brendan Rice

    Hi Jaime,

    I don't think the upgrade/migration part is the problem as I following all the Umbraco guidelines.

    I don't normally use App_Code either but it's an inherited project.

    Ignore the MySurfaceController thing (I was trying to simplify the example).

    The issue seems related to dependency injection, as the stack trace bombs on LightInject with an "unable to resolve type" error. This would suggest that the SurfaceController isn't registered in the DI pipeline at the point it tries to access it (I'm assuming App Start).

    Thanks for taking the time to respond. Any help is appreciated.

  • Larry Smalley 1 post 71 karma points
    Sep 08, 2021 @ 10:36
    Larry Smalley

    Hello Brendan Rice,

    I'm facing the exact issue with my Umbraco 8 Solution. Did You manage to solve this mycardstatement - if so, would You care to share...?

  • Brendan Rice 507 posts 942 karma points
    Sep 08, 2021 @ 17:10
    Brendan Rice

    No luck yet Larry. The issue has stabilised but if I frig with the Web.Config it'll blow up again.

    It seems like something to do with the way Umbraco is handling the Dependency Injection around surface controllers.

  • Erik Eelman 79 posts 318 karma points
    Sep 20, 2021 @ 13:55
    Erik Eelman

    Hi Brendan,

    You could try to register the controller via a Composer to see if this fixes your issue.

    You can do something like this:

    public class CmsSetupComposer : IUserComposer
        public void Compose(Composition composition)

    I found this in a issue op umbraco github:

Please Sign in or register to post replies

Write your reply to: