Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 10th, 2008, 05:30 AM
Registered User
Join Date: Apr 2008
Location: mumbai, maharashtra, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to mahen_pali Send a message via Yahoo to mahen_pali
Default Remoting in C#

Hi to all members
My problem is related to remoting in c#. there are three files
c.cs Customer file code
s.cs Server File Code
o.c Server side code which we call in C.CS

C.CS File
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
public class ccc
    public static void Main()
      TcpChannel c = new TcpChannel();
      zzz a = (zzz)Activator.GetObject(typeof(zzz), "tcp://localhost:8085/eee");
      if (a == null)
          System.Console.WriteLine("Could not locate server");

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
public class sss
    public static void Main()
          TcpChannel c = new TcpChannel(4444);
          RemotingConfiguration.RegisterWellKnownServiceType (
          Type.GetType("zzz,o"), "eee", WellKnownObjectMode.SingleCall);
          System.Console.WriteLine("Press <enter> to exit...");

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
public class zzz : MarshalByRefObject
    public zzz()
    public String abc()
          Console.WriteLine("Vijay Mukhi2");
          return "Sonal";

When I Comple and execute . it’s compile properly but not execute client code.
Server class execute successfully and give
 o/p Press <enter> to exit...

when I execute client code it’s this error
Unhandled Exception: System.Net.Sockets.SocketException: No connection could be
made because the target machine actively refused it

Server stack trace:
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre
ss socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.Runtime.Remoting.Channels.RemoteConnection. CreateNewSocket(EndPoint
   at System.Runtime.Remoting.Channels.RemoteConnection. CreateNewSocket()
   at System.Runtime.Remoting.Channels.SocketCache.GetSo cket(String machinePortA
ndSid, Boolean openNew)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTran sportSink.SendRequestWit
hRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTran sportSink.ProcessMessage
(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITranspor
tHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryClientForma tterSink.SyncProcessMess
age(IMessage msg)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage req
Msg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData& msgDa
ta, Int32 type)
   at zzz.abc()
   at ccc.Main()

My Problem : I am not getting which port I can use for remoting please help me to solve this problem


mahendra singh
  #2 (permalink)  
Old February 24th, 2009, 05:15 PM
Authorized User
Join Date: Nov 2006
Location: Valparaiso, IN, USA.
Posts: 93
Thanks: 0
Thanked 1 Time in 1 Post
Default re:Remoting in C#

I see two potential problems in your remote server application (S.CS). When you declare and instantiate the TcpChannel you use a different port than the client application uses.

TcpChannel c = new TcpChannel(4444);
The second may not be critical but the Type.GetType("zzz,o") function should have as an argument "<namespace>.<class>, <namespace>". I see the class "zzz" but I don't see that you assigned a namespace in the code you posted.

I think the main reason why it rejects your client application connection is the port though.
What you don\'t know can hurt you!

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remoting in c# mahen_pali C# 0 November 17th, 2008 10:17 AM
Remoting bhavana .NET Framework 1.x 0 November 12th, 2007 04:20 AM
remoting caribbean Pro VB.NET 2002/2003 0 May 16th, 2006 12:11 PM
Remoting manisha2578 VS.NET 2002/2003 1 June 29th, 2005 06:59 AM
Remoting.... kk_katepally General .NET 0 December 21st, 2004 05:07 AM

All times are GMT -4. The time now is 07:17 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.