Object reference not set to an instance of an object.

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
 
S

Sharon

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top