pbaali

pbaali

  • NA
  • 5
  • 0

.Net Remoting error Help Required

Aug 6 2004 7:56 AM
Hi All, I am running a .Net Remoting sample program. I got the following Error . // The underlying connection was closed: An unexpected error occurred on a receive. Server stack trace: at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessRespo nseException(WebException webException, HttpWebResponse& response) at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessa ge(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransp ortHeaders& responseHeaders, Stream& responseStream) at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessag e(IMessage msg) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req Msg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa ta, Int32 type) at RemoteInfo.RemoteBoys.getData() in e:\firstc#\classlibrary2\classlibrary2\ class1.cs:line 14 at RemoteClient.RmtClient..ctor() in e:\firstc#\remoteclient\remoteclient\cla ss1.cs:line 27 // Can anyone please tell what is wrong with the code . // Implementation class to be registered by the server and accessed by the client using System; using System.Runtime.Remoting; namespace RemoteInfo { public class RemoteBoys:MarshalByRefObject { private string custName; public RemoteBoys() { } public int getData() { return 300; } public string Name { set {custName = value;} get { return custName; } } } } //End // Server Class using System; using RemoteInfo; using System.Runtime; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels.Http; using System.Runtime.Remoting.Channels; namespace RemoteServer { class RmtServer { HttpServerChannel httpChannel = new HttpServerChannel(8085); public RmtServer() { ChannelServices.RegisterChannel(httpChannel); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteBoys), "RemoteBoys",WellKnownObjectMode.Singleton); } [STAThread] static void Main(string[] args) { new RmtServer(); } } } //Server End //Client using System; using System.Runtime; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels.Http; using System.Runtime.Remoting.Channels; using RemoteInfo; namespace RemoteClient { class RmtClient { HttpClientChannel clntChannel = new HttpClientChannel(); public RmtClient() { try { ChannelServices.RegisterChannel(clntChannel); RemoteInfo.RemoteBoys rb = (RemoteInfo.RemoteBoys) Activator.GetObject(typeof (RemoteBoys),"http://localhost:8085/RemoteBoys"); if(rb == null) { Console.WriteLine("Reference Not obtained"); } else { rb.getData(); // Error Occured and caught } } catch(Exception exe) { Console.WriteLine(exe.Message); Console.WriteLine(exe.StackTrace); } } [STAThread] static void Main(string[] args) { new RmtClient(); } } } // On executing the client the following exception was thrown in the console. please help me to get rid of this error Exception The underlying connection was closed: An unexpected error occurred on a receive. Server stack trace: at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessRespo nseException(WebException webException, HttpWebResponse& response) at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessa ge(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransp ortHeaders& responseHeaders, Stream& responseStream) at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessag e(IMessage msg) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req Msg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa ta, Int32 type) at RemoteInfo.RemoteBoys.getData() in e:\firstc#\classlibrary2\classlibrary2\ class1.cs:line 14 at RemoteClient.RmtClient..ctor() in e:\firstc#\remoteclient\remoteclient\cla ss1.cs:line 27 Regrards Balan.P