简体   繁体   English

WCF在向客户端发送响应之前抛出

[英]WCF throwing before sending response to client

I have a WCF service where IGameServices contains: 我有一个WCF服务,其中IGameServices包含:

[ServiceContract]
public interface IGameServices
{
    [OperationContract]
    DtoReturnedMessage<DtoGame> GetGame(Guid gameId);
}

AdminServices contains: AdminServices包含:

public class AdminService : IGameServices
{
    private readonly BoGame _boGame = new BoGame();

    public DtoReturnedMessage<DtoGame> GetGame(Guid gameId)
    {
        return _boGame.Get(gameId);
    }
}

I have that BoGame, which is a class with business logics. 我有BoGame,这是一门具有业务逻辑的课程。

My config is: 我的配置是:

 <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IGameServices" sendTimeout="00:05:00" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:50380/Services/Implementations/AdminService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGameServices"
            contract="IGameServices" name="BasicHttpBinding_IGameServices" />
    </client>
</system.serviceModel>

When I debug it step-by-step, all the business logics works properly, and throws the exception below when the response should be sent to the client. 当我逐步调试它时,所有业务逻辑都可以正常工作,并在将响应发送到客户端时在下面引发异常。

An error occurred while receiving the HTTP response to http://localhost:50380/Services/Implementations/AdminService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IGameServices.GetGame(Guid gameId)
   at GameServicesClient.GetGame(Guid gameId)

Inner Exception:
The underlying connection was closed: An unexpected error occurred on a receive.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

Inner Exception:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)

Inner Exception:
An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

It is weird because I have a method to save some data into the DB, in the same IGameServices, which saves normally and returns the success message as expected. 这很奇怪,因为我有一个方法可以在同一IGameServices中将一些数据保存到数据库中,该方法可以正常保存并按预期返回成功消息。

Does any one know what that can be? 有谁知道那是什么吗?

I solved the problem. 我解决了问题。 The error was too generic, actually. 实际上,该错误过于笼统。 The issue was with build versions of Postsharp not matching. 问题是Postsharp的构建版本不匹配。

I found it out by trying to open the services directly on the browser. 我试图通过直接在浏览器中打开服务来发现它。 I removed Postsharp in that project and BANG. 我删除了该项目中的Postsharp和BANG。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM