WCF Module Test Results in System.ServiceModel.FaultException

So, I have a WCF service that works fine in a deployed production environment. My build is interrupted, although during unit testing of this WCF service. The strange part is that it does not always match the unit test, but it is always the unit test that uses the WCF service.

An 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 strange part is that the exception really only happens on the build machine and never on the developer's machine. And it seems that this happens in about 75% of cases.

WCF is not my strongest aspect of .NET, so any help pointing me in the right direction would be helpful.

+3
source share
1 answer

, catch :

var proxy = new WcfProxy();

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

catch proxy.Abort() Close(), .

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

Source: https://habr.com/ru/post/1783966/


All Articles