.NET远程处理二进制格式化程序反序列化抛出;索引超出了数组的范围;

.NET远程处理二进制格式化程序反序列化抛出;索引超出了数组的范围;,.net,vb.net,serialization,remoting,.net,Vb.net,Serialization,Remoting,代码如下: Dim serverProv As New System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full Dim clientProv As New System.Runtime.Remoting.Channels.BinaryClie

代码如下:

Dim serverProv As New System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider
serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full
Dim clientProv As New System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider
Dim props As New System.Collections.Hashtable
props("port") = 0 ' Implies client should use an available port!
Dim m_channel As New TcpChannel(props,clientProv, serverProv)
ChannelServices.RegisterChannel(channel) 
iRemoteClientServer = CType(Activator.GetObject(GetType(ABC.XYZ.Interfaces.IClientServer),sAddress,ABC.XYZ.Interfaces.IClientServer)
iRemoteClientServer.Process(oContext) -- Object containing the data which is processed by a function Process in a windows service -- Thsi is the line that throws the exception shown above
当我们从安装了.NET framework 1.1、2.0和4.0的计算机上的VB.NET DLL向windows服务传递自定义对象时,会引发此错误。非常感谢您的帮助

System.IndexOutOfRangeException: Index was outside the bounds of the array.

Server stack trace: 
   at System.Runtime.Serialization.Formatters.Binary.ReadObjectInfo.GetMemberTypes(String[] inMemberNames)
   at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
   at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
   at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryRequestMessage(String objectUri, Stream inputStream, Boolean bStrictBinding, TypeFilterLevel securityLevel)
   at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

我只是想发布一个解决方案,说明从Microsoft安装此修补程序解决了这个问题:

如果没有更多信息,将很难为您提供帮助。异常本身是不言自明的-它发生在代码中的什么地方?我们从VB.NET dll远程处理到windows服务,并将哈希表作为参数传递给方法调用。在这个方法调用之前,我们只是在另一个调用中发送一个字符串,windows服务会正确地接收到它,但是当我们使用同一个服务器对象在另一个调用上发送哈希表时,调用甚至不会到达windows服务,它会出错并返回上述错误。同样的调用在只安装了Framework1.1(SP1)和2.0SP2的WindowsServer2003机器上也可以正常工作。但是,在win server 2008 r2机箱上,上述问题就表现出来了。这可能是一个框架问题-1.1在Windows 2003之后不受支持,但我相信,它可能会被欺骗而使用2008机箱(几个月前我不得不这么做)。嗨,蒂姆-谢谢你的回答-你做了什么才能欺骗它使用2008机箱?请详细说明,以便我可以看看它是否符合我的要求。我不记得确切的情况,但这个链接看起来就是我使用的链接: