sxb
sxb

Reputation: 1

I don't understand the stack trace from a clients website. System.NullReferenceException: Object reference not set to an instance of an object

The web application is asp mvc. I can't figure out what object reference not set to an instance of an object means. Is it database related or some ajax failing? I am not familiar with ASP MVC apps. And when I try to go to admin page, Index.apsx keeps getting injected in the wrong place in the url, what causes that?

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
BoatingSafety.Utils.CreateContext() in C:\inetpub\wwwroot\AppDevProjects\ASP.NET\BoatingSafety\BoatingSafety\SupportClasses\Utils.cs:27
BoatingSafety.Controllers.PageController.Index() in C:\inetpub\wwwroot\AppDevProjects\ASP.NET\BoatingSafety\BoatingSafety\Controllers\PageController.cs:31
lambda_method(ExecutionScope , ControllerBase , Object[] ) +40
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +53
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +258
System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +193
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +300
System.Web.Mvc.Controller.ExecuteCore() +104
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +36
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +59
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +54
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
System.Web.Mvc.MvcHttpHandler.VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) +54
System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContextBase httpContext) +111
System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContext httpContext) +40
System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) +7
BoatingSafety._Default.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot\AppDevProjects\ASP.NET\BoatingSafety\BoatingSafety\Default.aspx.cs:22
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Upvotes: 0

Views: 1592

Answers (1)

Leandro Soares
Leandro Soares

Reputation: 2972

NullReferenceException is a generic exception.

When you get this error, it means that somewhere in your project there is a non nullable protected sample of code or in other words, you are trying to call something that is null.

Example:

Class1 obj = new Class1();
obj.Prop1 = 0; // This is ok
obj = null; 
obj.Prop1 = 0; // This will throw System.NullReferenceException

See also

NullReferenceException Class

What is a NullReferenceException and how do I fix it?

Also:

Utils.CreateContext() in C:\inetpub\wwwroot\AppDevProjects\ASP.NET\BoatingSafety\BoatingSafety\SupportClasses\Utils.cs:27

PageController.Index() in C:\inetpub\wwwroot\AppDevProjects\ASP.NET\BoatingSafety\BoatingSafety\Controllers\PageController.cs:31

It occurs at the class Utils in the function CreateContext Line 27 and then bubble up to /Page/Index Line 31

PDB in production server

It seems that you have PDB in your client production server. It's not recommended.

See More

Upvotes: 1

Related Questions