CSharp.Net-Informations.com
   Home      .Net Framework      VB.NET      C#                                                                      About


  C# Remotable Object

Any object outside the application domain of the caller application should be considered as Remote Object . A Remote Object that should be derived from MarshalByRefObject Class. Any object can be changed into a Remote Object by deriving it from MarshalByRefObject . Objects without inheriting from MarshalByRefObject are called Non-remotable Objects.

The following example creating a Remote Object in C#, RemoteTime , which send the current time to the Client Application using Remoting Framework. The RemoteTime class is derived from MarshalByRefObject and inside the class it has a method getTime() which returns the current time from the Remote Object.

         C# Source Code Download           Print Source Code
         C# Remotable Object - Download
        
C# Tutorial

using System; 

public class RemoteTime : MarshalByRefObject 
{ 
    private string currentTime = ""; 
    
    public string getTime() 
    { 
        currentTime = DateTime.Now.ToShortTimeString(); 
        return "Remote Server Time : " + currentTime; 
    } 
}

Copy and paste the above C# source code into a file and save it as RemoteTime.vb
Compile the class RemoteTime.cs into a library using the command-line tools that shiped with the Visual Studio SDK .

At the command prompt type the following command:

  csc /t:library RemoteTime.cs

After you compile the RemoteTime.cs , you will get a file called RemoteTime.dll in the directory where your compiler resides.

If your file RemoteTime.cs is residing in c:\src then you should type command like the following :

  csc /t:library c:\src\RemoteTime.cs



Csharp Remoting Related Contents
*     C# Remoting Architecture
*     C# Remoting application
*     C# Remote Listener Object
*     C# Remote Client Object
*     How to run Remote Application
*     How to Remote Application Configuration
*     How to Remote Activation
*     How to Remoting Channels
*     How to Remoting Formatters


   Home      VB.NET      C#
CSharp Related Topics
*     An overview of Microsoft CSharp
*     C# Language Tutorial
*     C# Statements Tutorial
*     C# Collection Tutorial
*     C# String Tutorial
*     C# File Operations Tutorial
*     C# Excel Tutorial
*     C# Crystal Reports Tutorial
*     CSharp Communication Tutorial
*     C# Ado.Net Tutorial and Source Code
*     C# ADO.NET data Providers Tutorial
*     C# Dataset Tutorial
*     C# DataAdapater Tutorial
*     Csharp DataView Tutorial
*     Csharp Remoting Tutorial
*     C# XML Tutorial
*     C# DataGridView Tutorial
   Home      VB.NET      C#
More Source Code :   
Mail to :  feedback@net-informations.com
  |  Home   |  VB.NET   |  C#   |  SiteMap   |  Terms of Use   |  About   |
net-informations.com (C) 2010
All Rights Reserved. All other trademarks are property of their respective owners.