Global.ueuo.com
 Home 
 
 FreeOnlineBooks 
 
 FreeOnlineSoftware 
 
 InterviewQuestions 
 
 Dotnet 
 
 Java 
 
 PHP 
 
 SqlServer 
 
 ContactUs 
HTML
JavaScript
  • Bouncing Ball
  • Calculating the sum of digits
  •  
  • Counter
  •  
  • Clock  
  •  
  • Day of Week
  •  
  • Event Handler Examples
  •  
  • Jump List
  •  
  • Multiplication Table
  •  
  • Random Quotes
  •  
  • Slide Show & Slide Show version 2

  • CSS
  • Replacing Attributes in the BODY Tag
  • Increasing the Page Margins
  •  
  • Changing the Text Color
  •  
  • Changing the Page Background Color  
  •  
  • Changing the Visited Link Color
  •  
  • Adding a:hover for a Link Rollover Effect
  •  
  • Specifying a Font for the Whole Page
  •  
  • Creating and Applying a Class (1)
  •  
  • Creating and Applying a Class (2)
  •  
  • Acceptable Font Families

  • (*) Free Softwares  (*) FreeOnlineBooks  (*) SourceCodes  (*) Articals  (*) Games  (*) Projects  (*) Greetings  (*) Tutorials  (*) Programs  (*) Fourms 
    .Net Remoting
    
    
    .NET Remoting - Part 1
    Introduction to Remoting
    
    In this article we are going to learn the basics of Remoting, Marshalling, Channels , Formatters,Activation and Lifetime leases. 
    
    What is Remoting? 
    
    
    The .NET Remoting system allows clients to call methods on objects across remoting boundaries. Remoting enables the communication
     between the client and the server by creating proxy objects. 
    
    The Client and the Server Communicates by the following steps : 
    
    When a client object requests an instance of the server object, the remoting system at the client side creates a proxy of the server object.
    The proxy object behaves just like the remote object; this leaves the client with the impression that the server object is in the client's process.
    
    When the client object calls a method on the server object, the proxy passes the call information to the remoting system on the client.
    This remoting system, in turn, sends the call over the channel to the remoting system on the server. 
    
    The remoting system on the server receives the call information and, on the basis of this information, invokes the method on the actual 
    object on the server (creating the object, if necessary). 
    
    The remoting system on the server collects the result of the method invocation and passes it through the channel to the remoting system on the client. 
    The remoting system at the client receives the server's response and returns the results to the client object through the proxy. 
    
    Object Marshalling 
    
    
    Object Marshalling Specifies how a remote object is exposed to the Client Application. .NET Remoting offers us Object Marshalling by two ways 
    
    Marshal by Value ( MBV ) 
    These objects are copied from the Server Application Domain to the Client Application Domain 
    
    Marshal by Reference ( MBR ) 
    Clients just holds the reference to the Object and Proxy id used to access the Server 
    
    Marshal by Value 
    
    
    MBV should implement ISerialize interface or it should be marked with the SerializableAttribute so the the remoting system can serialize the objects.
    When a Client calls a method by MBV, MBV object is Serialized, transferred to the client machine. It will be an exact copy of the Server Side Object. 
    Now the object is available at the client side so we can make calls to any methods. 
    Since the object is copied to the client machine, it will reduce roundtrips to the Server. 
    So the execution will get faster. 
    
    
    [Serializable()] 
    public class MarshalByValueObject 
    { 
       //... 
    }
    
    
    Marshal by Reference ( MBR ) 
    
    
    MBR objects are remotable objects that must extend the System.MarshalByRefObject . 
    They always reside on Server. When a client creates an instance of MBR object, a proxy object is created on the Client Side which holds
     the reference  of the Server Side object. 
    
    
    public class MarshalByReferenceObject: MarshalByRefObject 
    { 
       //... 
    }
    
    
    We go for MBR when the object's size is large or when the functionality is available only on the Server. 
    
    Channels 
    
    
    Channels are used to transfer the details of the method call between Client and the Server. The .NET Framework provides the provides the :
    System.Runtime.Remoting.Channels namespace used to work with the channels. 
    
    All channels implement the Ichannel interface. The Channel Object on the receiving end will listen for the messages from the Client 
    using the particular channel and portnumber.
     The Channel object on the sending End will send the information to the receiving end using the same protocol and port number. 
    
    .NET Framework provides two type of Protocols for sending and receiving the Object. 
    
    HTTP Channel Implementations of the HTTP Channel is provided through the classes of System.Runtime.Remoting.Channels.Http 
    
    TCP Channel
    Implementations of the TCP Channel is provided through the classes of System.Runtime.Remoting.Channels.Tcp 
    
    If we want to define our own channel, we can do that implementing the IChannelReceiver and IChannelSender interfaces. 
    
    Formatters 
    
    
    Formatters are the objects that are used to encode, decode, serialize and deserialze the objects when they are passed to the over the network. 
    
    .NET Framework provides to common Formatters :
    
    SoapFormatter 
    Soap Formatter is implemented in the SoapFormatter class which can be found at System.Runtime.Serialization.Formatters.Soap 
    
    BinaryFormatter 
    Binary Formatter is implemented in the BinaryFormatter class which can be found at 
    
    System.Runtime.Serialization.Formatters.Binary 
    If you want to use the different formatter, you can do that by implementing the IFormatter interface. 
    
    Remote Object Activation 
    
    
    As we saw earlier, only MBR needs the activation of the objects remotely. ( In MBV, the object itself is copied to the client but
     not in the case of MBR )There are two types of Activation of objects available in Remoting 
    
    Server Activated Objects ( SAO ) 
    In server Activation, the objects are created when you firsta call a method from the client machine. The objects are not created in 
    when you use the new  keyword to create an instance 
    
    Client Activated Objects ( CAO ) 
    But in case of Client Activated Objects, the objects are created in the Server when you use the new keyword for creating the instance. 
    
    In Server Activated Objects, there are two types activation 
    
    Single Call Activation Mode 
    For each and every client, an object will be created . When the client finshes the requests, then the object will be deleted
    from the memory and .NET Framework regains its space. 
    
    Singleton Activation Mode
    In Singleton Activation, regardless how many clients, there will be only one object in the Server. It will serve for all the clients 
    
    Lifetime Leases 
    
    
    Lifetime lease is the duration for which the Object in the Server should reside in the memory. Both SAO and CAO have their 
    lifetime of their own. The lifetime lease works as follows. 
    
    Whenever the object is created, its lifetime lease ( CurrentLeaseTime ) is set using InitialLeaseTime property.
    By default the leasetime is 5 minutes. 
    When the object the receives a call, the lifetime will be increased by 2 minutes by default. We can set the renewal time too
    by coding using the Renew() method. 
    
    When the lease time reaches 0, then the object is marked for the garbage collection and it will be removed from the memory when
    Sponsol cannot renew leasetime. 
    
    In this Part 1 of remoting you learned about what is remoting and the basic concepts like Marshalling, Channels, Formatters etc.
    In the next part, we will go deep into the programming of remoting. 
    
     
    
    
    
    

    Latest SqlServerQuerys
    Certification