.Net remoting error “The input stream is not a valid binary format.”

在开发.Net Remoting的程序时,发现了如下异常消息:

The input stream is not a valid binary format. The starting contents (in bytes) are: 53-79-73-74-65-6D-2E-54-79-70-65-4C-6F-61-64-45-78 …

Server stack trace:
at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser input)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord()
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryResponseMessage(Stream inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

看了一头雾水吧,不知道到底哪里出错了。trace里的Serialization很会误导人。实际上真正的exception跟序列化没任何关系,出现上述错误信息的原因是,配的remoting的formatter是binary,所以Client端的Binary Formatter总是以二进制编码的格式去解析从Server端获取的返回值造成的,所以你把formatter改为soap之后,在运行就可以看到真正的错误信息了。

原创文章,转载请注明: 转载自闲云博客

本文链接地址: .Net remoting error “The input stream is not a valid binary format.”

发表评论

电子邮件地址不会被公开。 必填项已用*标注