New to Telerik Reporting? Download free 30-day trial

Run Time Problems. Unable to serialize the session state in 'StateServer', 'SQLServer' or 'Custom' mode.

Environment

Product Progress® Telerik® Reporting

Description

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

Solution

This exception might surface if you try to use objects which do not implement ISerializable for a Report/Data Item data source. For example, if this is an IList, you can try using a List instead as shown in our cars example. You can also use the NeedDataSource event of the report and assign the data source to the "processing report", thus avoiding any need for serialization/deserialization. Another approach is to use a DataSet/DataTable:

DataTable dt = new DataTable();
DataColumn col = new DataColumn("ColumnName", typeof(string));
//....
dt.Columns.Add(col);
foreach (object Item in MyIList)
{
    DataRow row = dt.NewRow();
    row["ColumnName"] = Item;
    //.....
    dt.Rows.Add(row);
}
In this article