Remoting failing on second call



Hi all,

I hope someone can help with this.

I am doing some work outs on remoting to understand it. I have a
remote server running on different machine. And i am trying to execute
the client on my machine. When i call the Message( ) method on the
remote object, it should send me a text across which i can print on my
console. Everything is happening fine at the first time.

The problem is,

When i rerun the client after it exits the first run, i am getting
exception as given below. To check further, I modified the client to
simply called the Message( ) method twice successively and executed.
This time i got the exception for the second method call while first
call works well.

Could you please let me know what i am missing?

Exception:
~~~~~~~~
at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
req
Msg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgDa
ta, Int32 type)

Client:
~~~~~
class RemClient
{
static void Main(string[] args)
{
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);

MyRemoting.RemotableObject remObj =
(MyRemoting.RemotableObject)Activator.GetObject(typeof(MyRemoting.RemotableObject),

"tcp://111.123.321.124:8080/Message");

if (remObj != null)
{
System.Console.WriteLine(remObj.Message());
System.Console.ReadLine();
System.Console.WriteLine(remObj.Message());
}
}

Server:
~~~~~
class RemotingServer
{
static void Main(string[] args)
{
TcpChannel channel = new TcpChannel(8080);
ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemoting.RemotableObject),

"Message", WellKnownObjectMode.Singleton);
Console.WriteLine("Press any key to exit...");
Console.ReadLine();
}
}

Object:
~~~~~
public class RemotableObject : MarshalByRefObject
{
public RemotableObject()
{
}
public string Message()
{
FileStream fs;
StreamReader sr;
string s = "",t;
fs =
File.Open(@"C:\Message.Txt",FileMode.Open,FileAccess.Read,FileShare.None);
sr = new StreamReader(fs);
while (true)
{
t = sr.ReadLine();
if (!(t==null))
{
s += t;
}
else
{
break;
}
}
return s;
}
}

Thanks,
Saran.

.



Relevant Pages

  • Re: soapsuds
    ... pre-instantiated exe running in a singleton mode, for remoting, even if you ... Revised framework implementations will probably not break your application ... We can then compile the client using this code which allows us ... Both client and server are ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Sending Messages and Sharing Objects
    ... RJ> are using CSLA framework by Rocky because it allows us to switch ... Web Service, Remoting or Simple ... RJ> since client requirements could vary. ... RJ> to use any of the channels - 2Tier, Web Service or Remoting ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: passing structs (setializable) object in web service
    ... The philosophy of webservices is different than that of remoting. ... follow Seely's advice as Christoph pointed out earlier - you have to modify ... > having total control over both client and server types. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • RE: Remoting client exception
    ... Microsoft Online Support ... | handler in .net remoting application.... ... | when we register a event handler of an remote object in our client ... | fucntion) will be dynamically invoked by the server object (when event is ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Events in .Net Remoting
    ... I am writing with respect to the Events in .Net Remoting that I had ... another channel for the callbacks..both on client side. ... Then I force a method on the server end (through a GUI control on the ... >> the regular client side requests still work fine. ...
    (microsoft.public.dotnet.framework.remoting)

Loading