我有一个使用.NET Remoting通信的客户端服务器应用程序。出于身份验证的原因,我不得不编写一个自定义的IClientChannelSink,以便将会话cookie插入HTTP请求。
在服务器端,我还编写了一个自定义IServerChannelSink,以从HTTP请求标头中读取服务器需要的一些信息。

客户端工作正常,但在服务器端我总是收到以下错误:


  用户代码Message = No未处理System.ArgumentNullException
  消息在调用DispatchChannelSink之前已反序列化。
  参数名称:requestMsg Source = mscorlib ParamName = requestMsg
  堆栈跟踪:
         在
  System.Runtime.Remoting.Channels.DispatchChannelSink.ProcessMessage(IServerChannelSinkStack
  sinkStack,IMessage requestMsg,ITransportHeaders requestHeaders,
  流requestStream,IMessage&responseMsg,ITransportHeaders&
  responseHeaders,Stream&responseStream)
         在
  MyAuthentication.MyServerChannelSink.ProcessMessage(IServerChannelSinkStack
  sinkStack,IMessage requestMsg,ITransportHeaders requestHeaders,
  流requestStream,IMessage&responseMsg,ITransportHeaders&
  responseHeaders,Stream&responseStream)
  C:\ Dev \ MyAuthentication \ MyServerChannelSink.cs:第82行
         在
  System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack
  sinkStack,IMessage requestMsg,ITransportHeaders requestHeaders,
  流requestStream,IMessage&responseMsg,ITransportHeaders&
  responseHeaders,Stream&responseStream)
         在
  System.Runtime.Remoting.Channels.Http.HttpServerTransportSink.ServiceRequest(对象
  州)
         在
  System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow()
  InnerException:


我的“ ProcessMessage”方法如下所示:

public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
{
    // Pre-processing before sending the message to the next sink in the chain
    object state = null;
    ProcessRequest(requestMsg, requestHeaders, ref requestStream, ref state);

    /* Call the next sink in the chain */
    sinkStack.Push(this, state);
    ServerProcessing serverProcessing = this.NextChannelSink.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream);

    // Processing from sink further in the chain has completed. Now do any post-processing before returning to the previous sink in the chain.
    ProcessResponse(null, responseHeaders, ref responseStream, state);

    return serverProcessing;
}


如果有人可以告诉我怎么了,那将很棒。

最佳答案

在某些情况下,requestMsg参数可以是
空值。因此,您必须处理这些情况。例如另一个服务器通道接收器
在将requestMsg设置为null的情况下调用ProcessMessage函数!

编辑:提供了指向示例的链接。
这是服务器接收器示例的链接:Server Sink

关于c# - 自定义.NET远程处理IServerChannelSink,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7095323/

10-10 04:23