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.
by: aacoolPosted on 2004-10-19 at 06:59:52ID: 12347273
Can you post your config files as well?