服务代码如下:
publicNorthwindEntitiesctx=newNorthwindEntities();
publicIQueryableGetOrders()
{
varquery=fromoinctx.Orders
selecto;
returnquery;
}
publicstringTest()
{
varquery=fromoinctx.Orders
selecto;
returnquery.First().Customers.CustomerID;
}
Test执行是可以的,GetOrders就报错:
接收对http://localhost:44217/Service1.svc的HTTP响应时发生错误。这可能是由于服务终结点绑定未使用HTTP协议造成的。这还可能是由于服务器中止了HTTP请求上下文(可能由于服务关闭)所致。有关详细信息,请参见服务器日志。
Serverstacktrace:
在System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebExceptionwebException,HttpWebRequestrequest,HttpAbortReasonabortReason)
在System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpantimeout)
在System.ServiceModel.Channels.RequestChannel.Request(Messagemessage,TimeSpantimeout)
在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Messagemessage,TimeSpantimeout)
在System.ServiceModel.Channels.ServiceChannel.Call(Stringaction,Booleanoneway,ProxyOperationRuntimeoperation,Object[]ins,Object[]outs,TimeSpantimeout)
在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessagemethodCall,ProxyOperationRuntimeoperation)
在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessagemessage)
Exceptionrethrownat[0]:
在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessagereqMsg,IMessageretMsg)
在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData,Int32type)
在IService1.GetOrders()
在Service1Client.GetOrders()
InnerException:
基础连接已经关闭:接收时发生错误。
在System.Net.HttpWebRequest.GetResponse()
在System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpantimeout)
InnerException:
无法从传输连接中读取数据:远程主机强迫关闭了一个现有的连接。。
在System.Net.Sockets.NetworkStream.Read(Byte[]buffer,Int32offset,Int32size)
在System.Net.PooledStream.Read(Byte[]buffer,Int32offset,Int32size)
在System.Net.Connection.SyncRead(HttpWebRequestrequest,BooleanuserRetrievedStream,BooleanprobeRead)
InnerException:
远程主机强迫关闭了一个现有的连接。
在System.Net.Sockets.Socket.Receive(Byte[]buffer,Int32offset,Int32size,SocketFlagssocketFlags)
在System.Net.Sockets.NetworkStream.Read(Byte[]buffer,Int32offset,Int32size)
分 -->
|