Sporadic error:" Object reference not set to an instance of an object."

M

Michel Couche

Hello,

I have an ASP.Net application that uses the Wizard control to build a newsletter.
There are three steps in the wizard.

The customer's specific design data are loaded from a database in step 1 of the wizard and saved into a session variable.

In step 2, when the user clicks on a button, I load the design data from the session variable and these are saved for further handling in a HashTable.

The HashTable is defined in the general declarations of the page class:
Dim HT_HTMLData As Hashtable

The code to load the hashtable is as follows:
Private Function Send_TestMail() As Boolean

Try



HT_HTMLData = Session("HTMLData") ' // Line X

.....

After loading the page on the production server, on some PC's everything is OK, no error message.

On other PC's I receive an "Object reference not set to an instance of an object" on line X. Some PC's receive this error more frequently than others. AFAIK, the error is not due to a timeout problem. The tests have been repeated and the inconsistency is consistant (... if I may say so ....)

Any help to solve this sporadic error will be most appreciated



Michel
 
M

Mark Fitzpatrick

First thing, you should always be testing to see if an item such as a session variable is null before you attempt to access it.

How many steps does this wizard have? Something to keep in mind, no matter how quick you think a user should be able to fill out a form, you may find they'll take four times as long.It's amazing how long some people can take to enter data. I recently broke a form down into a number of simple pieces, informed the users that they had less then 20 minutes to perform some action to save their data, and there was still an attempt to enter the data in for an hour. If they take longer than the normal session timeout, you're going to loose all their session data. Instead of storing the data as a session variable, you could, perhaps, store it in the viewstate or as a hidden form field.

It could be also that the application is recycling and loosing the session data once the application pool is recycled.


--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
Hello,

I have an ASP.Net application that uses the Wizard control to build a newsletter.
There are three steps in the wizard.

The customer's specific design data are loaded from a database in step 1 of the wizard and saved into a session variable.

In step 2, when the user clicks on a button, I load the design data from the session variable and these are saved for further handling in a HashTable.

The HashTable is defined in the general declarations of the page class:
Dim HT_HTMLData As Hashtable

The code to load the hashtable is as follows:
Private Function Send_TestMail() As Boolean

Try



HT_HTMLData = Session("HTMLData") ' // Line X

....

After loading the page on the production server, on some PC's everything is OK, no error message.

On other PC's I receive an "Object reference not set to an instance of an object" on line X. Some PC's receive this error more frequently than others. AFAIK, the error is not due to a timeout problem. The tests have been repeated and the inconsistency is consistant (... if I may say so ....)

Any help to solve this sporadic error will be most appreciated



Michel
 
G

Guest

Sorry to be pedantic, but one does not "loose" one's Session Data. My pants
may be loose. But when my Session is gone, it's because I "lose" it (with one
"o").
Cheers,
Peter
 
M

Michel Couche

Thank you Mark for your answer. I am sure if will help for this project but also I will use it as guidelines for future developments.
Michel

(to answer your question, it is a "3 steps" wizard)
First thing, you should always be testing to see if an item such as a session variable is null before you attempt to access it.

How many steps does this wizard have? Something to keep in mind, no matter how quick you think a user should be able to fill out a form, you may find they'll take four times as long.It's amazing how long some people can take to enter data. I recently broke a form down into a number of simple pieces, informed the users that they had less then 20 minutes to perform some action to save their data, and there was still an attempt to enter the data in for an hour. If they take longer than the normal session timeout, you're going to loose all their session data. Instead of storing the data as a session variable, you could, perhaps, store it in the viewstate or as a hidden form field.

It could be also that the application is recycling and loosing the session data once the application pool is recycled.


--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
Hello,

I have an ASP.Net application that uses the Wizard control to build a newsletter.
There are three steps in the wizard.

The customer's specific design data are loaded from a database in step 1 of the wizard and saved into a session variable.

In step 2, when the user clicks on a button, I load the design data from the session variable and these are saved for further handling in a HashTable.

The HashTable is defined in the general declarations of the page class:
Dim HT_HTMLData As Hashtable

The code to load the hashtable is as follows:
Private Function Send_TestMail() As Boolean

Try



HT_HTMLData = Session("HTMLData") ' // Line X

....

After loading the page on the production server, on some PC's everything is OK, no error message.

On other PC's I receive an "Object reference not set to an instance of an object" on line X. Some PC's receive this error more frequently than others. AFAIK, the error is not due to a timeout problem. The tests have been repeated and the inconsistency is consistant (... if I may say so ...)

Any help to solve this sporadic error will be most appreciated



Michel
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top