The remote host closed the connection. The error code is 0x80070057

后端 未结 2 907
失恋的感觉
失恋的感觉 2020-12-24 15:45

I\'m getting a lot of these error messages in my logs on one of my servers and intermittently on two others.

Googling didn\'t reveal very much information, mostly re

2条回答
  •  遥遥无期
    2020-12-24 16:17

    Are you returning a Stream?

    You might need to close it after the method finishes.

    Check out this: Closing Returned Streams in WCF

    Here is the code this blog suggests:

    public Stream GetFile(string path) 
    {
       Stream fileStream = null;    
    
       try   
       {
          fileStream = File.OpenRead(path);
       }
       catch(Exception)
       {
          return null;
       }
    
       OperationContext clientContext = OperationContext.Current;
       clientContext.OperationCompleted += 
           new EventHandler(delegate(object sender, EventArgs args)
           {
                if (fileStream != null) fileStream.Dispose();
           });
       return fileStream;
    }
    

提交回复
热议问题