Last post Jan 12, 2015 10:38 AM by PatriceSc
Jan 05, 2015 01:52 PM|Brian-RESCH|LINK
I have my ASP.NET web app set up to use ASP.NET State Server, it will save objects that are serialize of course to it, however sometimes I run into an inherited object that is marked as serializeable but the base class is not. When this happens it will not
save to the state server and just give me a null reference for the object key. No exceptions are thrown, is there anyway to catch this happening so I can see an error when it happens or something else to tell me an attempt was made to save a non-serializable
object to the session state server?
Jan 05, 2015 02:15 PM|Siva Krishna Macha|LINK
You might have got "SerializationException".
Also check InnerException for more details as in
Jan 05, 2015 02:38 PM|Brian-RESCH|LINK
No, I get nothing! That's my issue, I did have an inherited object which I missed and was trying to persist to the session state server, it would never save, after tracing back up it's inheritance path found one that wasn't serializable and switched it and
it worked fine... there was no serialization exceptions thrown that I could find it was almost like something caught it and threw it out before it bubbled up to the debugger even with break on exceptions set for that exception, I get nothing..
Jan 05, 2015 02:50 PM|Siva Krishna Macha|LINK
Probably you might have tried this but in case if you've not tried - Could you put try catch block around Session set statement and see if that gives any exception?
Session["abcd"] = "some object";
catch (Exception ex)
Jan 05, 2015 04:07 PM|Brian-RESCH|LINK
nope, no exception... when i pass in an inherited object that the base class is not serializable but the child class is. can't figure out why this exception is not being thrown
Jan 05, 2015 10:27 PM|Summer - MSFT|LINK
Thank you for your post.
As far as I know, save non-serializeable objects to Session State server is not a wise choice, because it can damage application reliability.
Further information please refer to the link below.
Jan 06, 2015 10:02 AM|Brian-RESCH|LINK
I think you missed the point of my post... I am trying *NOT* to do this, but I ran across some inheirance issues where the base class was not marked as serializable, I wanted to catch this if it happened, but I get no exceptions when it does just a null
object in the state server session
Jan 06, 2015 11:26 AM|AidyF|LINK
Storing non-serialisable objects in the Session when you are using state server does create an exception. It is likely that something in your code is catching this exception and doing nothing with it. We don't have access to your code so it is impossible
to tell. Create a brand new empty project, configure it to use state server and see what happens when you store non-serialisable items in the Session.
Jan 08, 2015 11:56 AM|Brian-RESCH|LINK
already did that, and it didn't throw an exception, this is why I am stuck
Jan 12, 2015 10:38 AM|PatriceSc|LINK
I gave this a try but don't see this behavior. I *do* have an exception if the parent class is not marked as serializable. What if you try just that in a project sample or if you give the code for the simplest classes that would show this behavior (or try
to start simple to see if it happens and add until you find this behavior).
Ah or could it be that it happens in a Ajax call or something and that the exception is not logged?