I have inherited the ASP.NET e-commerce web application (C # code behind). We recently moved the servers, and this is somewhat difficult. I have very little experience setting up an IIS server and working with such large projects. Most of the problems are now fixed, but we are having problems with a decisive role, as the client is trying to make a payment.
When the client confirms the payment, the application detects the following error:
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.
Stack trace:
[SerializationException: Type 'PayerAuthentication.PayerAuthenticationServicePost' in Assembly 'PayerAuthentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.] System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +7733643 System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +258 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +111 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +161 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +51 System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +410 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +134 System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1577
Google search results indicate that I should add [Serializable] to the declared class declaration, but this is in a compiled dll to which I do not have csproj. The code worked fine on the previous server, and I do not think that any changes were made to the code, only in web.config - what can I do?
The sessionstate section of the web.config file reads <sessionState mode="StateServer" />
UPDATE1 . Using Reflector, I exported the class above, made it serializable, recompiled and replaced the dll. The ordering process went through another step, where I encountered the same error for another compiled class. Once again, I was able to use Reflector to see the code, and then export it, edit it, and recompile it.
Now I have the same error:
SerializationException: Type 'System.Runtime.Remoting.Messaging.AsyncResult' in Assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.]
I'm not sure I can do anything about this, as this should be part of the .net system files! Any other ideas?
UPDATE2 : Ha, I subsequently discovered that it was processing payments correctly, but then threw the Unable to serialize the session state error above on System.Runtime.Remoting.Messaging.AsyncResult before the user received the transaction. Not good. Not sure how to move on ...
UPDATE3 . I tried to create a copy of the System.Runtime.Remoting.Messaging.AsyncResult class and make it serializable, but this leads to inconsistent accessibility issues.
using System; using System.Runtime.InteropServices; using System.Threading; using System.Security.Permissions; using System.Runtime.Remoting.Messaging; [Serializable, ComVisible(true)] public class myAsyncResult : IAsyncResult, IMessageSink {
In particular, this is error CS0122: 'System.Runtime.Remoting.Messaging.Message' is inaccessible due to its protection level . I see this because Message is an inner class. But of course, I cannot change the accessibility level, because it is part of the System.Runtime namespace. And by making a copy and renaming it, will it fix the same problem again?
Can anybody help me?
FINAL UPDATE It seems, after all this, that it was an SSL certificate (see My answer below)