Remoting failing on second call
- From: sxsrira@xxxxxxxxx
- Date: 12 Dec 2006 23:09:38 -0800
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.
.
- Follow-Ups:
- Re: Remoting failing on second call
- From: Markus
- Re: Remoting failing on second call
- Prev by Date: Re: .NET Remoting, Windows Service host, load balancing
- Next by Date: Re: Remoting failing on second call
- Previous by thread: Remoting...Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.
- Next by thread: Re: Remoting failing on second call
- Index(es):
Relevant Pages
|
Loading