object reference not set to an instance of an object.............
when this problem arise?

Recommended Answers

All 7 Replies

object reference not set to an instance of an object.............
when this problem arise?

in general OOP, if you are trying to access properties or methods of class without creating or instantiating object of that class then runtime throws this error. See the below code which throws error :
StringBuilder sbTest;
sbTest.Appen("employee name");

The red highlighted portion in above code throws the error as we haven't created the object of StringBuilder and we are trying to append string.

I hope it may help to you.

Mark it as solved if it solve your problem.

When you use sessions this error arises when there is no value to bind in Session and you use it somewhere else.

hey it's not only for session, if you are using viewstate and there is no value to bind and you use it , you will get this error. Also if you are using request.querystring("") and don't have correct key then also the same error throws.

basically when u r object is null which can be session or any object you can think of...if it is null and still you try to access it...then you get the error..

basically when u r object is null which can be session or any object you can think of...if it is null and still you try to access it...then you get the error..

yes that's exactly what i am trying to say that it's not only for session or view state or query string but it's for any object. :-)

sorry bro dnt be maddy i didn't read your post... :-(

sorry bro dnt be maddy i didn't read your post... :-(

np bro...:-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.