"汇编"中的类型''未标记为可序列化.LINQ到SQL

Cha*_*ris 3 c# sql-server linq-to-sql asp.net-session

我正在使用asp.net并已将会话配置为存储在SQL Server中.我的项目有很多对象和几个linq-to-sql dbml.我已将所有这些配置为单向序列化,并进行了一些自定义更改.

当我运行应用程序时,我在application_error事件处理程序中不断收到此错误

在程序集'App_Code.thzd8p2j中输入'Data.Karaoke.spCWP_SelUserPrivilegesResult',Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null'未标记为可序列化.

从错误中我不确定它是否来自dbml.designer.cs文件,这是代码:

[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));
}
Run Code Online (Sandbox Code Playgroud)

[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;
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

如何确定错误源自何处?或者错误是什么意思?

我不确定如何解决或寻找解决问题的方法.

Art*_*nez 6

您似乎在应用程序中运行某种类型的序列化.序列化不同于DataContract序列化.

创建一个新文件并输入以下内容:

[Serializable]
public partial class spCWP_SelUserPrivilegesResult { }
Run Code Online (Sandbox Code Playgroud)

如果从数据库刷新dbml文件,则在单独的文件中执行此操作.