468,292 Members | 1,491 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,292 developers. It's quick & easy.

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

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



Apr 3 '07 #1
3 2562
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
"Michel Couche" <Co*****@MichelCouche.netwrote in message news:eO**************@TK2MSFTNGP02.phx.gbl...
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



Apr 3 '07 #2
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

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Michel Couche" wrote:
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


Apr 3 '07 #3
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)
"Mark Fitzpatrick" <ma******@fitzme.comwrote in message news:ux**************@TK2MSFTNGP04.phx.gbl...
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
"Michel Couche" <Co*****@MichelCouche.netwrote in message news:eO**************@TK2MSFTNGP02.phx.gbl...
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



Apr 3 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.