C#程序“System.ArgumentOutOfRangeException: 不是有效的 Win32 FileTime”问题解决

问题:

    C#程序在使用hessian调用java程序时报“System.ArgumentOutOfRangeException: 不是有效的 Win32 FileTime”异常,该异常不是每次都出现,而是在选择日期范围不同时会出现。

Exception by proxy call
System.ArgumentOutOfRangeException: 不是有效的 Win32 FileTime。
参数名: fileTime
   在 System.DateTime.FromFileTimeUtc(Int64 fileTime)
   在 hessiancsharp.io.CHessianInput.ReadObject()
   在 hessiancsharp.io.CMapDeserializer.ReadMap(AbstractHessianInput abstractHessianInput)
   在 hessiancsharp.io.CSerializerFactory.ReadMap(AbstractHessianInput abstractHessianInput, String strType)
   在 hessiancsharp.io.CHessianInput.ReadObject()
   在 hessiancsharp.io.CMapDeserializer.ReadMap(AbstractHessianInput abstractHessianInput)
   在 hessiancsharp.io.CSerializerFactory.ReadMap(AbstractHessianInput abstractHessianInput, String strType)
   在 hessiancsharp.io.CHessianInput.ReadObject()
   在 hessiancsharp.io.CObjectDeserializer.ReadMap(AbstractHessianInput abstractHessianInput, Object result)
   在 hessiancsharp.io.CObjectDeserializer.ReadMap(AbstractHessianInput abstractHessianInput)
   在 hessiancsharp.io.CHessianInput.ReadObject(Type expectedType)
   在 hessiancsharp.io.CCollectionDeserializer.ReadGenericList(AbstractHessianInput abstractHessianInput)
   在 hessiancsharp.io.CCollectionDeserializer.ReadList(AbstractHessianInput abstractHessianInput, Int32 intListLength)
   在 hessiancsharp.io.CHessianInput.ReadObject(Type expectedType)
   在 hessiancsharp.io.CHessianInput.ReadReply(Type expectedType)
   在 hessiancsharp.client.CHessianMethodCaller.DoHessianMethodCall(Object[] arrMethodArgs, MethodInfo methodInfo)不是有效的 Win32 FileTime。
参数名: fileTime

 

解决:

   hessian调用返回的是一个列表,输入参数有起始时间,经过反复测试,只是在某个时间段才会发生该异常。通过二分法逐步缩小范围,定位到一天的数据,这天数据中有一条记录的日期为“0001-01-03 00:00:00.0”,该日期看起来不怎么正常,通过查询资料得知,Hessian中处理时间时,当时间早于1601年1月1日时,产生异常错误(见后面的参考链接)。

  将改条数据修改为2018年,错误消失。

  这个问题最后的解决虽然很简单,连程序都不用改,但是查找问题原因却花费了很多的时间。在排查问题时,还是应该从相关性来考虑,既然报错为日期错误,就应该首先围绕日期排查问题的所在,前面一直在考虑是不是记录数过多的问题(因为缩小时间范围就不报错),而真正的原因是:缩小时间范围,有问题的记录没有被包含在内。

 

 

 

参考:

http://digital.ni.com/public.nsf/allkb/880D1CF3D1A6810286257B9700483B07

你可能感兴趣的:(C,sharp)