I changed sessionState mode from InProc to StateServer in web.config of DataSetDemo. Then I got the following error:
The DataSetDemo sample application creates a System.Data.DataSet instance as a session variable. The DataSet contains DataRows.
According to the error message:
“In ‘StateServer’ mode, ASP.NET will serialize the session state object, and as a result non-serializable objects or MarshalByRef objects are not permitted.”
Also according to the error message:
“System.Data.DataRow in Assembly ‘System.Data …’ is not marked as serializable.”
So no ASP.NET application with a DataSet in a session variable can be run in StateServer mode. It can’t be serialized and so is disallowed.
However, while DataSetDemo creates the DataSet in memory to avoid dependencies on any particular database product, the same is not true of most applications. In a typical database application you can create a DataSet and bind it to a particular database each time a transaction is need. That will avoid the need to serialize the DataSet and should avoid the problem.
Thanks for the reply. It is very helpful.
Can you point out in the DataSetDemo, where is the statement that creates a System.Data.DataSet instance as a session variable? I could not find out any statement that assigns dataset to a session variable.
What I found out is in app_code\datasetmapper.vb, Function CreateNodesFromDataSetTable, there are 2 statements:
myGoDocument.Add(node)
nodes.Add(row(keyField), node)
If I comment out both lines, the page will NOT bomb (of course it does not do anything either). As long as one of them is not commented out, the page bombs. So my question is where is the session varible assignment occurs? It is inside the goWeb dll or somewhere else in the demo code?
Thanks a lot.