【问题标题】:.NET Remoting Binary Formatter Deserialization throws "Index was out of bounds of array".NET Remoting 二进制格式化程序反序列化抛出“索引超出数组范围”
【发布时间】:2012-09-30 06:10:56
【问题描述】:

这是代码:

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

当我们将自定义对象从 VB.NET DLL 传递到 Windows 服务时,会引发此错误 这是在安装了 .NET framework 1.1、2.0 和 4.0 的机器上。非常感谢这里的任何帮助。

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)

【问题讨论】:

  • 如果没有更多信息,将很难为您提供帮助。异常本身是不言自明的——它出现在代码的什么地方?
  • 我们从一个 VB.NET dll 远程处理到一个 Windows 服务,并且我们将一个哈希表作为参数传递给方法调用。在此方法调用之前,我们只是在不同的调用中发送一个字符串,它会被 Windows 服务正确接收,但是当我们通过具有相同服务器对象的不同调用发送哈希表时,该调用甚至不会到达 Windows 服务,并且会出现错误以上错误。相同的调用在仅安装了框架 1.1 (SP1) 和 2.0 SP2 的 Windows Server 2003 机器上运行良好。但在 win server 2008 r2 机器上,上述问题就显现出来了。
  • 这可能是一个框架问题 - 我相信 Windows 2003 之后不支持 1.1,尽管它可以被骗到在 2008 年的机器上工作(几个月前我不得不这样做)。
  • 嗨蒂姆-感谢您的回答-您必须做什么才能诱使它在 2008 年的盒子上工作?请详细说明,以便我在这里查看它是否符合我的要求。
  • 我记不太清了,但这个链接看起来是我用的那个:Installing .Net 1.1 applications on Windows Server 2008 R2

标签: .net vb.net serialization remoting


【解决方案1】:

只想发布从 Microsoft 安装此 HotFix 解决此问题的解决方案:http://archive.msdn.microsoft.com/KB907262/Release/ProjectReleases.aspx?ReleaseId=772

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-17
    • 2023-02-04
    相关资源
    最近更新 更多