Problem with casting Session state cached data
Posted on 2004-08-28
Hello, new to .Net (using c#). I've created a stronly typed collection, which I've marked as serializable, so that I can pass it into the session cache and get it back out again for either displaying or updating at a later point. Problem is once I've put it into the session I can't seem to get it back out again because I'm getting the error "Specified cast is not valid" on this line:
DataSet ds = (DataSet)Session["myCahedData"];
I've decorated both my class and another other class, which acts as a placeholder for the collection of the aforemetioned objects, as serializable. I can use these just fine in the initial build of this collection, display the contents by binding it to a grid, as well as putting it into the session object, like so:
Session["myCachedData"] = myCol.GetArrayList();
The error leads be to belive that the collection isn't serialized, but that's not the case. Perhaps I'm not putting this into the session state correctly in the first place? this is a time sensitve issue. thanks in advance!!