Without seeing more of your code it's difficult to say. However, the following is a good set of guidlines to accessing Session variables in a safe way.
public DataSet MyDataSet
{
get
{
return Session["MyDataSet"] as DataSet;
}
set
{
Session["MyDataSet"] = value;
}
}
That was you reduce the chance of getting errors where you accidentally mistype the key string that goes in the indexer property because they will only exist twice. Secondly, the property is strongly typed. You only get a DataSet out, and you can only put a dataset in. There is no chance you accidentally put the wrong object into the Session. You will only get null out if there is nothing in the session. If you do this manually each time there is the possibility of an error putting the wrong object in the session and the Session["VariableName"] as DataSet returning null. You also mentioned that it works in Debug Mode. Are you doing anything differenly in debug builds? Do you have and #if DEBUG ... #endif blocks anywhere? --Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown) Enumerators in .NET: See how to customise foreach loops with C#