mardi 5 mai 2015

.Net - Serializable issue with List with Session stored in SQL Server

We are using .Net 4.0 and SQL Server for our Session Store.

We have marked all our objects as [Serializable] but we are still getting the error:

System.Web.HttpException (0x80004005): Unable to serialize the session state.

In turns out the issue is with a call to a ToList method we have implemented

if (licenseHoldings != null && licenseHoldings.**ToList()**.Any())

And the implementation of LicenseHoldings contains this method

public List<License> ToList()
    {
        var list = new List<License>();

        if (SerializableObject != null)
            list.Add(SerializableObject);

        return list;
    }

Appreciate any guidance on why a List of a serializable object is not serializable to a SQL Server session and on an alternative implementation to this method.

Aucun commentaire:

Enregistrer un commentaire