您的位置:首页 > 其它

.Net Remoting Exception: BinaryFormatter Version Incompatibility

2004-10-28 04:51 746 查看
.Net Remoting Exception: BinaryFormatter Version Incompatibility

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

Exception Message:

An unhandled exception of type 'System.Runtime.Serialization. SerializationException' occurred in mscorlib.dll

Additional information: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 1008738336.1684104552.

注:由IIS承载Remote Objects,并且采用BinaryFormatter和HTTPChannel。

然后在Ingo Rammer的web site-.Net Remoting FAQ发现了对上述异常信息的分析及其解决办法,详见下面的Reference 1。

*** Cause ***

其实这和Version Incompatibility完全没有关系,事实上是由于Client端的Binary Formatter总是尽量以二进制编码的格式去解析从Server端获取的返回值造成的。

假设Server端Remote Objects出现异常,返回如下异常信息:

HTTP/1.1 500 Internal Server Error

……

事实上,Client端却以二进制编码的格式来解析,它首先检查header头,寻找Server端使用的Serializer版本号,结果没有接受到版本号,而是读取"<htm...",并解析为"1008738336.1684104552"。然后比较1.0和1008738336.1684104552,并认为发生Version Incompatibility异常。

*** Solution ***

没有通用的解决办法,一般而言这是Server端Remote Objects内Remote method发生异常。不过,可以按照如下的思路进行分析:

1,确保Remote Objects部署正常

可以通过《如何检测Remote Objects是否部署成功》来进行验证。

2,使用Simon Fell提供tcpTrace工具来捕获Client与Server间传输的数据

(1)先从http://www.pocketsoap.com 下载tcpTrace工具。

(2)然后,需要将Client和Server端的BinaryFormatter改为SOAPFormatter,否则tcpTrance也只是简单捕获Header信息,没有SOAP消息体的信息。

(3)启动tcpTrace,并配置参数:

Listen on Port #: 81
Destination Server: localhost
Destination Port #: 80

假设Remote Server为localhost,并且port为80,然后Listen on Port设置为:81(当然可以为其他)。

下一步需要调整Client端Configuration file或者Source code,连接的Server URL设置为81(而不是80)。

(4)通过分析tcpSoap的SOAP消息,查看Server真正返回的异常信息,找到真正的错误。

上述技术仅对SAO(wellknown)对象有用。对CAO对象而言,由Server端产生URL并包含真正的Port号。

解决问题后,最后别忘了恢复Client端Port。

References:

1, Ingo Rammer, .Net Remoting FAQ, http://www.thinktecture.com/Resources/RemotingFAQ/BINARYVERSIONMISMATCH.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐