开发者

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

开发者 https://www.devze.com 2023-03-13 05:56 出处:网络
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 serializati

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, V开发者_如何学Cersion=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.


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.


don't know if it's the case for SQL Server CLR, but with .Net in general, I would adivse you to update your code to :

[Serializable()]
[DataContract()]
public partial class spCWP_SelUserPrivilegesResult
{
    ...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号