Very very strange error on test (and sometimes live) enviroment


I am upgrading a site to the latest version of EPiServer and for one page I get this very strange error on the test enviroment that I do not get in development. The error is:

System.InvalidOperationException: An error occurred when trying to create a controller of type 'CUSTOMER.Web.Controllers.Pages.JobController'. Make sure that the controller has a parameterless public constructor. ---> System.MissingMethodException: No parameterless constructor defined for this object.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
--- End of inner exception stack trace ---
at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

And the message is true, there are no parameterless constructor for this controller, but it has always worked before and it is working in development. Part of the controller looks like this:

 public class JobController : BaseController
        private readonly IJobAdsRepository _jobadsrepository;
        private readonly IKandidatProfilManager _kandidatProfilManager;
        private readonly IJobbManager _jobbManager;
        private readonly IService _iService;

        public JobController(IJobAdsRepository jobadsrepository, IKandidatProfilManager kandidatProfilManager, IJobbManager jobbManager, IService iService)
            _jobadsrepository = jobadsrepository;
            _kandidatProfilManager = kandidatProfilManager;
            _jobbManager = jobbManager;
            _iService = iService;

Since I do never get it in the development enviroment it is very hard to find, and when I get it in test-enviroment it takes very long time to get the page/error, the page just stay and loading for many a minute or so.

Has anyone else seen this?

Aug 04, 2014 16:45

Yes I did experience exact this error, in my case we used NHibernate that was causing the error, I think Structuremap was the real reason, and NHibernate used Structuremap if I remember correctly.

So if that's the case this may help you:


Aug 04, 2014 17:00

The strange thing is that it is only happening in the test enviroment (have not deployed this version to production yet).
I will look into it more tomorrow

Aug 05, 2014 20:28

Finally I got remote debugging to work and the error was a simple mistyping when doing a manual deploy for this branch. I had pointed out the wrong nHibernate.config file in web.config so it was pointing to the one that should be transformed.

This gave this strange end-error but when debugging I got error in Structuremap with a lot of innerexceptions last pointing to this error: "The '' attribute is not declared."

Thanks Johannes for pointing me in the right direction!

Aug 06, 2014 10:01
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.