Object reference not set to an instance of an object.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
we developed an ASP.NET Application, then our QA Dept make a full QA in all
pages with all possible cases, after deployment and review the error log we
noticed that many of errors which make page to be crashed refered to error
(Object reference not set to an instance of an object.)

so , what is the best techniques to avoid such errors in advance?
or in other to eliminate occurence such error, because our log if filled
with it :(

Regards
 
Hi Raed.
NullReferenceException is thrown, when you try to use an
instance of a reference type, that is null or nothing in VB.
You should check that the instance is not null, before you preform any
operation on it.

C#
if(instanceName == null)
{
Response.Write("error");
}

VB
if instanceName is nothing then
Response.Write("error")
end if

Hope this helps.
Sharon.
 
Back
Top