serialization of entity model c#

I am getting this error from time to time with serialization and I don't know which file I need to serialize. The pages are on and off one time they load other time they don't. Here is the error I am getting:

System.Web.HttpException (0x80004005): 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. ---> System.Runtime.Serialization.SerializationException: Type 'System.Data.Entity.DynamicProxies.Product_CC06DC79809AC788823D74B88F94CCB7155ADCE697911AF73214FB8B5F2B2EB4' in Assembly 'EntityFrameworkDynamicProxies-Nop.BusinessLogic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable. at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) at System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) at System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) at System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) at System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer) at System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) at System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length, Boolean compressionEnabled) at System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) at System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

So basically what I think is something with the entity model but I want to know how I can serialize that. Thanks in advance, Laziale

Answers


System.Data.Entity.DynamicProxies.Product (Error with this class)

Should add [DataContract] attribute on class and [DataMember] on fields like that

using System.Runtime.Serialization;
[DataContract]
public class Account
{
    [DataMember]
    public System.Guid ID { get; set; }
    [DataMember]
    public System.Guid AccountSubTypeID { get; set; }
    [DataMember]
    public Nullable<int> IndustryTypeID { get; set; }
}

Need Your Help

How to configure maven-release to use Perforce as SCM provider?

maven maven-3 perforce maven-release-plugin maven-scm

I am trying to use the maven release plugin to create a released version of a Java project having Perforce as the SCM.