当调用wcf, 小心返回值包含enum越界的错误。

前段时间处理过一个调用wcf的exception(那是一个非常奇怪的exception, 经过line by line的调试,exception是在调用出wcf operation的时候抛的):

System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:59.9730000'. ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:59.9730000'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

 

今天又遇到这个exception,而且都是在刚出wcf operation 调用的时候抛得,但郁闷的是我们竟然忘了上次是什么原因造成,怎么解决的了。

今天只能由重新调查,第一感觉可能是server和client的接口定义不一致的,但通过调查,包括使用wcftestclient测试,发现感觉是错误的。

但错误是怎么导致的?通过comment一些代码测试后,大家终于搞清楚了原因,最让我们感到脸红的是这个错误跟前段时间处理的exception完全是同一个问题导致的,竟然我们都忘记了原因。

 

所以再此记录下来:

这个原因:在返回client的结构中有一个enum的属性越界了,那是因为server代码没有检查enum是否越界,直接强制转换成enum. 当从server返回client一个越界的enum就产生了那个exception.

 

汗。

转载于:https://www.cnblogs.com/lxg226/archive/2010/09/27/1837048.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值