Type '' in Assembly '' is not marked as serializable. linq-to-sql

19,769

It seems like you are running some type of serialization in your application. A serialization different than DataContract Serialization.

Create a new file and enter the following:

[Serializable]
public partial class spCWP_SelUserPrivilegesResult { }

You do this in a separate file in case you refresh your dbml file from the database.

Share:
19,769
ChampChris
Author by

ChampChris

Updated on June 05, 2022

Comments

  • ChampChris
    ChampChris almost 2 years

    I am using asp.net and have configured the sessions to stored in SQL server. My porject has many object and several linq-to-sql dbml's. I have configured all the them to have unidirectional serialization and also made a few customized changes.

    When I run the app I keep getting this error in my application_error event handler

    Type 'Data.Karaoke.spCWP_SelUserPrivilegesResult' in Assembly 'App_Code.thzd8p2j, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

    from the error I am not sure if it is coming from the dbml.designer.cs file which this is the code:

    [Function(Name="dbo.spCWP_SelUserPrivileges")]
    public ISingleResult<spCWP_SelUserPrivilegesResult> spCWP_SelUserPrivileges([Parameter(Name="IDCWPUser", DbType="Int")] System.Nullable<int> iDCWPUser)
    {
      IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), iDCWPUser);
      return ((ISingleResult<spCWP_SelUserPrivilegesResult>)(result.ReturnValue));
    }
    

    and

    [DataContract()]
    public partial class spCWP_SelUserPrivilegesResult
    {
    
      private int _IDTypeCWPModule;
    
      private string _TypeKey;
    
      private bool _Security;
    
      public spCWP_SelUserPrivilegesResult()
      {
      }
    
      [Column(Storage="_IDTypeCWPModule", DbType="Int NOT NULL")]
      [DataMember(Order=1)]
      public int IDTypeCWPModule
      {
        get
        {
          return this._IDTypeCWPModule;
        }
        set
        {
          if ((this._IDTypeCWPModule != value))
          {
            this._IDTypeCWPModule = value;
          }
        }
      }
    
      [Column(Storage="_TypeKey", DbType="VarChar(10) NOT NULL", CanBeNull=false)]
      [DataMember(Order=2)]
      public string TypeKey
      {
        get
        {
          return this._TypeKey;
        }
        set
        {
          if ((this._TypeKey != value))
          {
            this._TypeKey = value;
          }
        }
      }
    
      [Column(Storage="_Security", DbType="Bit NOT NULL")]
      [DataMember(Order=3)]
      public bool Security
      {
        get
        {
          return this._Security;
        }
        set
        {
          if ((this._Security != value))
          {
            this._Security = value;
          }
        }
      }
    }
    

    How can I determine where the error originated from? Or what does the error mean?

    i am unsure how to solve or what to look for to solve the issue.