I have created a simple remoting server inside a Window Service as :
TcpChannel tcpChannel = new TcpChannel(8085);
ChannelServices.RegisterChannel(tcpChannel,true);
WellKnownServiceTypeEntry entry = new WellKnownServiceTypeEntry("RemotingWindowSrvc", "RemotingWindowSrvc.MailFormat", "MailFormat", WellKnownObjectMode.SingleCall);
RemotingConfiguration.RegisterWellKnownServiceType(entry);
Then we try and make call to this server in my client as:
private void GetRemoteObject()
{
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
MailFormat obj = (MailFormat)Activator.GetObject(typeof(MailFormat), "tcp://localhost:8085/MailFormat");
obj.sendUserRegistration("...");
}
}
ChannelServices.RegisterChannel(tcpChannel,true);
WellKnownServiceTypeEntry entry = new WellKnownServiceTypeEntry("RemotingWindowSrvc", "RemotingWindowSrvc.MailFormat", "MailFormat", WellKnownObjectMode.SingleCall);
RemotingConfiguration.RegisterWellKnownServiceType(entry);
Then we try and make call to this server in my client as:
private void GetRemoteObject()
{
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
MailFormat obj = (MailFormat)Activator.GetObject(typeof(MailFormat), "tcp://localhost:8085/MailFormat");
obj.sendUserRegistration("...");
}
}
MailFormat: is the name of the Class, being called here.
But upon calling "obj.sendUserRegistration("...");", client hangs indefinitely.
please help me with this.
Thanks,
Puneet
puneetshadijaPosted Sep 1, 2009, 1:40 AM
I have been able to solve this problem. posting it, so that it can be of help to other people like me... or if I can get some better suggestion on solving this problem.
It was hanging cause, it wasn't able to resolve the function name. But once I signed the assembly and deployed it in GAC, it was able to recognize it and call the function.
I am putting the code for your reference(dummy code in VB.NET, later converted to C#):
Dim ch As TcpChannel = New TcpChannel(8085)
ChannelServices.RegisterChannel(ch)
RemotingConfiguration.RegisterWellKnownServiceType( _
GetType(TrialClassLib.MailFormat), "myRemoteObject", WellKnownObjectMode.Singleton)