2013-03-27 35 views
-1

在我的下面的应用程序中,我生成类'JobManager'的列表。WCF异常,而返回列表<T>

List<JobManager> 

访问数据库和填写我的清单工作完美。看起来将这样的列表返回给我的客户是有问题的。

详细,我的代码看起来像这样

IService Class 

OperationContract(Name = "ReadJobQueue")] 
    [FaultContract(typeof(FaultException))] 
    List<JobManager> AccessManager(List<string> status,string process, string dtFrom, string dtTo); 


Service : IService 

public List<JobManager> AccessManager(List<string> status, string process, string dtFrom, string dtTo) 
    { 
     //return 'new List<JobManager>()' does work, without any data being filled. 
     return new JobBuilder(status, process, dtFrom, dtTo); 
    } 



[DataContract] 
public class JobManager 
{ 
    List<JobManager> _jobManagerchildren = new List<JobManager>(); 

    [DataMember(IsRequired = true, Order = 0)] 
    public string Description { get; set; } 

    [DataMember] 
    public List<JobManager> JobManagerChildren 
    { 
     get { return _jobManagerchildren; } 
     internal set { _jobManagerchildren = value; } 
    } 
} 

internal class JobBuilder : List<JobManager> 
{ 
    public JobBuilder(List<string> status, string process, string dtFrom, string dtTo) 
     : base() 
    { 
     DataTable dt = new Database().AccessJobQueue(status, process, dtFrom, dtTo); 

     foreach (DataRow row in dt.Rows) 
     { 
      Add(new JobManager { Description = row[1].ToString(), JobManagerChildren = JobDetail(row[0].ToString()) }); 
     } 
    } 

... 
} 

我错过了什么我JobManager类?

编辑错误码/异常

System.Net.Sockets.SocketException: 一个现有的连接被远程主机 贝System.Net.Sockets.Socket.Receive(字节[]缓冲液封闭, INT32偏移,INT32大小 ,的SocketFlags的SocketFlags) 贝System.ServiceModel.Channels.SocketConnection.ReadCore(字节[]缓冲液,诠释 32偏移,INT32大小,时间跨度超时,布尔闭合) ---恩德DER internenAusnahmestapelüberwachung - - bei System.ServiceModel.Channels.SocketConnection.ReadCore (Byte [] buffer,Int 32 offset,int32 size,TimeSpan timeout,布尔关闭) bei System.ServiceModel.Channels.SocketConnection.Read(Byte [] buffer,Int32 ffset,Int32 size,TimeSpan timeout) bei System.ServiceModel.Channels.DelegatingConnection.Read(Byte [] buffer,Int 32 offset,Int32 size,TimeSpan timeout) bei System.ServiceModel.Channels.ConnectionStream.Read(Byte [] buffer,Int32 o ffset,Int32 count ) 贝System.Net.FixedSizeReader.ReadPacket(字节[]缓冲液,的Int32偏移的Int32 计数) 贝System.Net.Security.NegotiateStream.StartFrameHeader(字节[]缓冲液,的Int32 偏移的Int32计数,AsyncProtocolRequest asyncRequest) bei System.Net.Security.NegotiateStream.ProcessRead(Byte [] buffer,Int32 offs et,Int32 count,AsyncProtocolRequest asyncRequest) --- Ende der internenAusnahmestapelüberwachung--- bei System.Net.Security.NegotiateStream.ProcessRead (Byte [] buffer,Int32 offs et,Int32 count,AsyncProtocolRequest asyncRequest) bei System.Net.Security.NegotiateStream.Read(Byte [] buffer,Int32 offset,Int 32 count) bei System.ServiceModel.Channels。 StreamConnection.Read(字节[]缓冲液,的Int32ö ffset,的Int32大小,时间跨度超时) ---恩德DER internenAusnahmestapelüberwachung---

服务器ST ACK迹: 贝System.ServiceModel.Channels.StreamConnection.Read(字节[]缓冲液,的Int32ö ffset,的Int32大小,时间跨度超时) 贝System.ServiceModel.Channels.SessionConnectionReader.Receive(时间跨度添 EOUT) 贝System.ServiceModel.Channels.SynchronizedMessageSource.Receive(时间跨度吨 imeout) 贝System.ServiceModel.Channels.FramingDuplexSessionChannel.Receive(时间跨度 超时) 贝System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceive(倍 锅超时,消息&消息) bei System.ServiceModel.Dispatcher.DuplexChannelBinder。请求(消息messag 即,时间跨度超时) 贝System.ServiceModel.Channels.ServiceChannel.Call(字符串动作,布尔ö 纽威,ProxyOperationRuntime操作,对象[]项,对象[]奏,时间跨度TI meout) 贝System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCal lMessage包括methodCall,ProxyOperationRuntime操作) 贝System.ServiceModel.Channels.ServiceChannelProxy.Invoke(即时聊天消息)[0]时

异常重新抛出: 贝System.Runtime。 Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage re qMsg,IMessage retMsg) bei System .Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData & msgD ATA,的Int32类型) 贝WcfSys.Shared.IService.AccessManager(List`1状态,字符串处理,S 特林dtFrom,字符串dtTo) 贝WcfSys。 Server.Program.Main()in WcfSys.Ser ver \ Program.cs:Zeile 66.

+1

这里我们再说一遍:*什么是错误信息?* – 2013-03-27 10:41:02

+0

好吧,我在几秒钟内编辑主帖。 – Insight 2013-03-27 10:53:40

回答

0

实际上,您发送回客户端的是List<JobManager>,但实际上它是派生类。因此,有固定的这两种方法:从JobBuilder

  1. 复制所有条目到一个新的List<JobManager>并返回新的列表
  2. JobBuilder一个DataContract,太。

方式 - 通过OOP原则 - 它知道你回来的对象是JobBuilder,运行时尝试序列的JobBuilder实例。但是,这不是WCF通信的知道类型。