I have a class which I want to put session:
[Serializable]
public class Model
{
private readonly List<Uri> uris;
public Model()
{
uris = new List<Uri>();
}
public IEnumerable<Uri> Uris { get { return uris; } }
}
An instance of this class and some strings are added to Session. Sql SessionState is used.
My problem is that sometimes when I get the Model object from session, the uris field is null. Please be noticed that all other primitive type session items are still correct.
I’m using ASP.NET 4.0 btw.
Could anyone please explain to me how this can happen?
Thank you in advance 🙂
I knew what happened here. The real cause involves some additional conditions:
1. Code is obfuscated.
2. Error happens when new code (update) is deployed and old session is still inuse.
Everytime code is obfuscated, fields and properties get random fuzzy names. Therefore, when sessionstate is deserialized, their values are null.