?
Solved

Remoting problem

Posted on 2004-10-19
8
Medium Priority
?
423 Views
Last Modified: 2008-01-09
Hi all,

I need to crate a two way communication between client and server using Remoting. I have a Dll file in which I keep two interfaces. Let's call them IA and IB. IA is implemented by the server's class A and IB is implemented by the client's class B.
The main goal is to send an object of type IB (an instance of B) that is created on the client, through a method on an object of type IA (an instance of A) theat is created by the server.

Well, the server exposes A using Remoting and the client receives it. The client can call methods and properties on A (easy, because it knows the interface IA) and even can pass the B object throgh a certain method. BUT, whenever I try to call a method on B (using the IB interface) I fail.

What am I doing wrong?

Here are Interfaces.cs, Client.cs, Server.cs and error description:

**********************Interfaces*********************
using System;

namespace Interfaces
{
      public interface IA
      {
            string Name
            {
                  get;
            }
            
            void SetClient(IB b);
            
      }      

      public interface IB
      {
            string Name
            {
                  get;
            }            
      }
}
*****************************************************

************************Server**********************
using System;
using System.Runtime.Remoting;

using Interfaces;


namespace Server
{
      [Serializable]
      class A: MarshalByRefObject, IA
      {
            [STAThread]
            static void Main(string[] args)
            {
                  RemotingConfiguration.Configure("RemotingListener.config");
                  Console.ReadLine();
            }            
            
            #region IA Members

            public string Name
            {
                  get { return "Server"; }
            }

            public void SetClient(IB b)
            {
                  Console.WriteLine(b.Name);
            }

            #endregion
      }
      
}
*****************************************************

************************Client**********************
using System;
using System.Runtime.Remoting;

using Interfaces;

namespace Client
{
      [Serializable]
      class B: MarshalByRefObject, IB
      {      
            [STAThread]
            static void Main(string[] args)
            {      
                  
                  RemotingConfiguration.Configure("ClientSideRegistrar.config");                  
                  IA a = (IA)Activator.GetObject(typeof(IA), "http://localhost:8989/A.rem");                                                

                  B b = new B();
                  a.SetClient(b);            

                  Console.ReadLine();
            }                        

            #region IB Members

            public string Name
            {
                  get
                  {
                        return "Client";
                  }
            }

            #endregion
      }
}

*****************************************************

************************Error description**********************
An unhandled exception of type 'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll

Additional information: System.ArgumentNullException: No message was deserialized prior to calling the DispatchChannelSink.
Parameter name: requestMsg
   at System.Runtime.Remoting.Channels.DispatchChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.Http.HttpServerTransportSink.ServiceRequest(Object state)
   at System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow()
*******************************************************************


Ophir.
0
Comment
Question by:ophirg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Expert Comment

by:aacool
ID: 12347273
Can you post your config files as well?

0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 12347678
This is tricky, since it will allow the server to do remoting calls to the client, which in turn requires the client to be able to receive such calls. Make sure that your configuration is correct so that the server can also reach the client, and that the client listens correctly for server calls.
0
 
LVL 1

Author Comment

by:ophirg
ID: 12349538
Solved it by myself.

Thank you for your time, guys.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Expert Comment

by:aacool
ID: 12351995
That's not a very helpful question and solution - you had people waiting on your question, without an explanation what is wrong - Mods?
0
 
LVL 1

Author Comment

by:ophirg
ID: 12352231
I am sorry for the inconvenience. I will post the solution tomorrow morning when I am at work.

Ophir.
0
 
LVL 1

Author Comment

by:ophirg
ID: 12355401
Hello all,

The solution is in the config files. Notice how I registered both as a service and as a client:

******************************Server config******************************
<configuration>
      <system.runtime.remoting>
            <application>
                  <service>
                        <wellknown
                              mode="Singleton"
                              displayName = "A"
                              type="Server.A, Server"
                              objectUri="A.rem"
                        />
                  </service>
                  <client>
                        <wellknown
                              type="Interfaces.IB, Interfaces"
                              displayName="B"
                              url="http://localhost:8989/B.rem"
                        />
                  </client>
                  <channels>
                        <channel ref="http" port="8989">
                              <serverProviders>
                                    <formatter
                                          ref="binary"
                                          typeFilterLevel="Full"
                                    />
                              </serverProviders>
                              <clientProviders>
                                    <formatter ref="binary"/>                              
                              </clientProviders>
                        </channel>      
                  </channels>
            </application>
      </system.runtime.remoting>
</configuration>
*********************************************************************


******************************Client config******************************
<configuration>
   <system.runtime.remoting>
      <application>
         <client>
            <wellknown
               type="Interfaces.IA, Interfaces"
               displayName="A"
               url="http://localhost:8989/A.rem"
            />
         </client>
         <service>
                        <wellknown
                              mode="SingleCall"
                              displayName = "B"
                              type="Client.B, Client"
                              objectUri="B.rem"
                        />
                  </service>
         <channels>
                  <channel ref="http"      port="0">
                        <clientProviders>
                              <formatter ref="binary"/>                              
                        </clientProviders>
                        <serverProviders>
                              <formatter ref="binary" typeFilterLevel="Full"/>
                        </serverProviders>
                  </channel>                  
         </channels>
      </application>
   </system.runtime.remoting>
</configuration>

*********************************************************************



That is it. I will gladly read your comments on this subject.

Thank you all,
Ophir.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12632838
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question