Chandra Zheng Chandra Zheng - 1 year ago 162
ASP.NET (C#) Question

An unhandled exception occurred during the execution of the current web request. ASP.NET

I just ran my program and I got this error message


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.


with stack trace

[NullReferenceException: Object reference not set to an instance of an object.]
OverseasCreditCard.Default.Page_Load(Object sender, EventArgs e) +667
System.Web.UI.Control.LoadRecursive() +70
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3177


I am using ASP.NET C#, does anyone know what happened?

Answer Source

Incomplete information: we need to know which line is throwing the NullReferenceException in order to tell precisely where the problem lies.

Obviously, you are using an uninitialized variable (i.e., a variable that has been declared but not initialized) and try to access one of its non-static method/property/whatever.

Solution: - Find the line that is throwing the exception from the exception details - In this line, check that every variable you are using has been correctly initialized (i.e., it is not null)

Good luck.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download