?
Solved

Remoting problem

Posted on 2004-10-19
8
Medium Priority
?
424 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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

649 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