简体   繁体   English

WCF单元测试结果在System.ServiceModel.FaultException中

[英]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. 所以我有一个WCF服务似乎在部署的生产环境中完美运行。 My build intermittently fails though during the unit testing of this WCF service. 我的构建在此WCF服务的单元测试期间间歇性地失败。 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. 奇怪的是,它并不总是相同的单元测试,但它始终是使用WCF服务的单元测试。

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. 它似乎只发生在75%的时间。

WCF isn't my strongest aspect of .NET so any help pointing me in the correct direction would be useful. WCF不是我最强大的.NET方面,所以任何指导我正确方向的帮助都会很有用。

This issue ended up being that inside a catch clause we had: 这个问题最终成为我们在一个catch子句中的内容:

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子句应该使用proxy.Abort()作为Close()可以抛出另一个异常。

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

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

相关问题 自承载WCF和System.ServiceModel.FaultException - Self-Hosting WCF and System.ServiceModel.FaultException System.dll中的System.ServiceModel.FaultException - System.ServiceModel.FaultException in System.dll 如何克服System.ServiceModel.FaultException - how to overcome System.ServiceModel.FaultException System.ServiceModel.FaultException - 如何解决这个问题 - System.ServiceModel.FaultException - how to solve this System.ServiceModel.dll中的“ System.ServiceModel.FaultException”:过程不存在 - 'System.ServiceModel.FaultException' in System.ServiceModel.dll: Procedure not present System.ServiceModel.FaultException - System.ServiceModel.FaultException<DefaultFaultContract not catching some exceptions 如何解决此错误“ System.ServiceModel.FaultException” - How can i solve this error “System.ServiceModel.FaultException” 在Dynamics CRM中将RetrieveMultiple与FetchXML一起使用时,出现“ System.ServiceModel.FaultException`1” - 'System.ServiceModel.FaultException`1' when using RetrieveMultiple with FetchXML in Dynamics CRM XAMARIN.ANDROID 应用出现 System.ServiceModel.FaultException - XAMARIN ANDROID app got System.ServiceModel.FaultException Synergy dbr.exe在xcall期间获取System.ServiceModel.FaultException - Synergy dbr.exe getting System.ServiceModel.FaultException during xcall
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM