And yet one more update ... I have found the problem with our sub-classed Typed DataSets. A guy on the
www.asp.net forums pointed out that I needed to have an additional constructor in my sub-class as follows:
public MyTypedDataSet(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
Once I added that everything now works fine and I don't have to bother with the DiffGram workaround. Much better!!
~~Bonnie
>In case anyone is interested in this thread, I have an update on the situation. It appears that the problem is *not* with Typed DataSets, but we further sub-class the auto-generated Typed DataSets and it's our sub-classes that refuse to de-serialize (not sure why, they should be fine and work in all other situations). But, rather than try to figure out why, I decided on the workaround that I mentioned earlier with a slight adjustment. I'm serializing the DataSet to a DiffGram and saving that to the Session variable. It works fine and preserves any changes to the DataSet.
>
>So, FYI ....
>
>~~Bonnie
>
>
>>I'm getting different behavior when saving a DataSet to SessionState ... differences between using the default in-process Session vs saving Session to SQL Server.
>>
>>When using a regular DataSet, all seems to work just fine. But, when using a Typed DataSet (which all our DataSets are), it doesn't work for SQL Sessions but works fine for the in-memory Sessions. Any idea why? I get an error about deserializing the DataSet.
>>
>>Here's how I was doing this (where this.oData is a Typed DataSet):
>>
>>// to save to Session
>>Session["oData"] = this.oData;
>>
>>// to retrieve from Session
>>this.oData = (MyDataSet)Session["oData"];
>>
>>
>>I've worked around it for now by serializing the DataSet to XML and saving the XML string as the Session variable and then getting it back into the DataSet with ReadXML() (but I may run into other problems with that ... not sure yet how this will affect deleted rows ... I'm still researching this).
>>
>>Anyone know why the behavior is different? Why should it not work just because I'm saving the Session variable to SQL? Anything else I need to do differently?
>>
>>~~Bonnie