Solved

Remoting problem

Posted on 2004-10-19
8
421 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

737 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