Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. .NET Remoting question

.NET Remoting question

Scheduled Pinned Locked Moved C#
questioncsharpsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asad Hussain
    wrote on last edited by
    #1

    I'm new to remoting and not very articulate so bear with me here. I have an object that needs to be queried by a remote client but it inherits from some other class already.

    public MyClass : SomeBaseClass
    { 
      public string GetName { return "name"; }
    }
    

    So I made a remoting object like so

    public class RemotingObject : MarshalByRefObject 
    {
      private MyClass c;
      
      public RemotingObject( ) { }
    
      public setClass( MyClass start )
      { c = start; }
    
      public string GetName( )
      {
        return c.GetName( );
      }
    }
    

    and a server like so

    public class RemotingServer
    {
    	public RemotingServer()
    	{
    		TcpChannel channel = new TcpChannel( 8080 );
    		ChannelServices.RegisterChannel( channel );
      
    		RemotingConfiguration.RegisterWellKnownServiceType( 
    			typeof( RemotingObject ), 
    			"RemotingObject", 
    			WellKnownObjectMode.Singleton );
    	}
    }
    

    My question is that how can I pass a MyClass object to the remotable object after it is created? Is is possible to pass it in the constructor of the remotable object? Thanks.

    S 1 Reply Last reply
    0
    • A Asad Hussain

      I'm new to remoting and not very articulate so bear with me here. I have an object that needs to be queried by a remote client but it inherits from some other class already.

      public MyClass : SomeBaseClass
      { 
        public string GetName { return "name"; }
      }
      

      So I made a remoting object like so

      public class RemotingObject : MarshalByRefObject 
      {
        private MyClass c;
        
        public RemotingObject( ) { }
      
        public setClass( MyClass start )
        { c = start; }
      
        public string GetName( )
        {
          return c.GetName( );
        }
      }
      

      and a server like so

      public class RemotingServer
      {
      	public RemotingServer()
      	{
      		TcpChannel channel = new TcpChannel( 8080 );
      		ChannelServices.RegisterChannel( channel );
        
      		RemotingConfiguration.RegisterWellKnownServiceType( 
      			typeof( RemotingObject ), 
      			"RemotingObject", 
      			WellKnownObjectMode.Singleton );
      	}
      }
      

      My question is that how can I pass a MyClass object to the remotable object after it is created? Is is possible to pass it in the constructor of the remotable object? Thanks.

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      A remote object is like another object, you can indeed pass it as a constructor parameter. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups