2011-06-14 39 views
3

我正在使用asp.net並已將會話配置爲存儲在SQL Server中。我的項目有很多對象和幾個linq-to-sql的dbml。我已經將它們配置爲具有單向序列化,並且還進行了一些自定義更改。類型''in Assembly''未標記爲可序列化。 linq-to-sql

當我運行應用程序,我不斷收到此錯誤在大會「App_Code.thzd8p2j我Application_Error事件

類型「Data.Karaoke.spCWP_SelUserPrivilegesResult」,版本= 0.0.0.0,文化=中性公鑰= 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)); 
} 

[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; 
     } 
    } 
    } 
} 

我怎麼能確定在哪裏錯誤源於? 或者錯誤是什麼意思?

我不確定如何解決或尋找什麼來解決問題。

回答

0

不知道這是否是爲SQL Server CLR的情況,但與.net在一般情況下,我會adivse您更新代碼:

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

我做了這些改變,現在我得到這個錯誤...類型'System.Linq.EnumerableQuery'1 [Data.Entities.msPlaylistItem]'不能序列化。考慮使用DataContractAttribute屬性標記它,並使用DataMemberAttribute屬性標記要序列化的所有成員。有關其他支持的類型,請參閱Microsoft .NET Framework文檔。 – ChampChris 2011-06-14 16:25:07

6

好像你正在運行某種類型的序列化在您的應用程序。與DataContract序列化不同的序列化。

創建一個新的文件,並輸入以下內容:

[Serializable] 
public partial class spCWP_SelUserPrivilegesResult { } 

你這樣做在一個單獨的文件中的情況下,你刷新從數據庫中你的dbml文件。

相關問題