StructureMap null reference exception when calling ASP.NET MVC Controller

242 views
Skip to first unread message

Georgia Mackey

unread,
Sep 20, 2017, 1:38:44 PM9/20/17
to structuremap-users

I am having an issue and i'm stumped so I'm hoping someone can help.

I am clicking a button on my webpage (view) and it should call a controller method but instead it looks like structuremap is having an issue building the controller. I know everything is built properly because a) this has been in production for years and b) the link i'm following when I get the error is from the same controller.

I am unable to reproduce this on my dev machine. Could anyone give me some advice on how to troubleshoot?

2017-09-19 08:00:45,231 [563] ERROR WebPortal.Global [(null)] - Object 
reference not set to an instance of an object.   at 
WebPortal.Controllers.EnrollmentController..ctor(ISystemUtility 
systemUtility, IObjectAdapter`2 userToCurrentUserViewModelAdapter, ILogger 
logger)
at lambda_method(Closure , IBuildSession , IContext )

2017-09-19 08:00:45,184 [563] ERROR WebPortal.Global [(null)] - Error while 
building type WebPortal.Controllers.EnrollmentController.  See the inner 
exception for details
1.) new EnrollmentController(*Default of ISystemUtility*, *Default of 
IObjectAdapter<User, CurrentUserViewModel>*, *Default of ILogger*)
2.) WebPortal.Controllers.EnrollmentController
3.) Instance of WebPortal.Controllers.EnrollmentController
4.) Container.GetInstance(WebPortal.Controllers.EnrollmentController)
at lambda_method(Closure , IBuildSession , IContext )
at StructureMap.Building.BuildPlan.Build(IBuildSession session, IContext 
context)
at StructureMap.SessionCache.GetObject(Type pluginType, Instance instance, 
ILifecycle lifecycle)
at StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph 
pipelineGraph)
at StructureMap.Container.GetInstance(Type pluginType)
at 
WebPortal.InjectableControllerFactory.GetControllerInstance(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)

Jeremy Miller

unread,
Sep 20, 2017, 3:14:28 PM9/20/17
to structure...@googlegroups.com
That’s not a StructureMap error per se. Something inside of your constructor function is hitting a NullReferenceException.


--
You received this message because you are subscribed to the Google Groups "structuremap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structuremap-us...@googlegroups.com.
To post to this group, send email to structure...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/structuremap-users/a918bcc7-abb7-4d64-b233-6e6b599cf889%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages