开发者

WCF Unit Testing Results in a System.ServiceModel.FaultException

So I have a WCF service that seems to work perfectly in a deployed production environment. My build intermittently fails though dur开发者_如何学编程ing the unit testing of this WCF service. The weird part is that it's not always the same unit test, but it is always a unit test which uses the WCF service.

Exception:

System.ServiceModel.FaultException[System.ServiceModel.ExceptionDetail]: The number of bytes available is inconsistent with the HTTP Content-Length header.  There may have been a network error or the client may be sending invalid requests.

The weird part is that the exception really only happens on the build machine and never on a developer machine. And it seems to only happen about 75% of the time.

WCF isn't my strongest aspect of .NET so any help pointing me in the correct direction would be useful.


This issue ended up being that inside a catch clause we had:

var proxy = new WcfProxy();

try
{
  // Do something.
}
catch (Exception ex)
{
  proxy.Close();
  throw;
}

Where the catch clause should have used proxy.Abort() as Close() can throw another exception.

catch (Exception ex)
{
  proxy.Abort();
  throw;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜