【发布时间】:2009-12-01 15:47:12
【问题描述】:
当我浏览似乎有效的演示时,我无法弄清楚这一点。我有一个 WCF 服务,我正在尝试使用 Linq to SQL。但是,我得到的只是错误 System.Data.Linq.Table 无法序列化。因此,我从自己的班级开始,认为我可以将其重新构建,直到出现错误。问题是即使尝试使用空类我也会收到错误消息。仅在我的方法上使用“As System.Linq.Table(Of xxx)”就会出现此错误。
无法序列化类型“System.Data.Linq.Table`1[LinqADMRequest2b]”。考虑使用 DataContractAttribute 属性对其进行标记,并使用 DataMemberAttribute 属性标记您想要序列化的所有成员。有关其他支持的类型,请参阅 Microsoft .NET Framework 文档。
Imports System.ServiceModel
Imports System.ServiceModel.Activation
Imports System.Runtime.Serialization
Imports System.Collections.Generic
Imports Linq
<ServiceContract(Namespace:="")> _
<ServiceBehavior(IncludeExceptionDetailInFaults:=True)> _
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class ComplyTrackWCFService
_
Public Function GetTestRequests() As System.Data.Linq.Table(Of LinqADMRequest2b)
'Dim ct As New Linq2.ComplyTrackDataContext()
'Dim queryresults = ct.ADMRequests 'ct.ADMRequestGetListByUser("", "155")
'Return queryresults
End Function
End Class
<DataContract()> _
<Serializable()> _
Public Class LinqADMRequest2b
Implements ISerializable
Private _firstName As String
_
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal Value As String)
_firstName = Value
End Set
End Property
Public Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData
End Sub
End Class
如您所见,GetTestRequests() 没有做任何事情,然后说它将返回 System.Data.Linq.Table(Of LinqADMRequest2b)
我无法让 LinqADMRequest2b 序列化。
无法序列化类型“System.Data.Linq.Table`1[LinqADMRequest2b]”。考虑使用 DataContractAttribute 属性对其进行标记,并使用 DataMemberAttribute 属性标记您想要序列化的所有成员。有关其他支持的类型,请参阅 Microsoft .NET Framework 文档。
【问题讨论】:
标签: linq wcf linq-to-sql serialization