Jun 21, 2010

Dotnet Remoting - Simple Overview

* Remoting is nothing but from an application we can call remote objects that is in the same computer or on different.

 

* Remoting is nothing but communication between two application domains.

 

* Remoting is nothing but cross process communication called Marshalling

* Two types of marshalling

 - Marshal by value(MBV): server creates a copy of the object and passes onto the client

 - Marshal by Reference(MBR): Client creates a proxy and then uses that proxy to access the object.

 MBV is better for small objects and MBR is better for large objects.

 

* A channel is an object that implements communication between a client and a remote object. There are two types of channels.

 - HttpChannel - formats messages into xml SOAP format

 - TCPChannel - binary format

 While creating server class that contains remote object, you also define and register one or more channels for the class and  associate each channel with a specific port. In the client, your code also creates a channel associated with a specific   port, and then uses the Activator class to obtain a reference to the remote object.

 

 

Remoting Overview

==================

 

To build Remote application we need the three parts

1) A remotable object.

2) A host application domain to listen for requests for that object.

3) A client application domain that makes requests for that object.

 

How Remoting works ?

 

When client creates an object using "new" for remotable object, then the remoting system creates a proxy of the remotable object and returns the reference to the client. When the client calls a method of the remotable type it actually call the method on the created proxy. The remoting system receives that call and routes it to the server process, it then processes the request, and returns the result to the client proxy, which in turn returns it to the client application.

 

Channels:- We will use channels to communicate across application domain boundaries. We used channels to send and receive messages. Channels are objects responsible of handling the network protocols(HTTPChannel, TCPChannel) and serialization formats on your behalf

 

namespace used is System.Runtime.Remoting

 

1) Building a Remotable Type

 

- If you want to call an object of a class from outside of application domain, then the class must inherit from "MarshalByRefObject" class.

 

Ex:-

Public Class TheRemotableObject

    Inherits MarshalByRefObject

 

    Private List As String() = {"String1", "String2", "String3"}

    Public Function ViewItem(ByVal ItemNum As Integer) As String

 

        If ItemNum > List.GetUpperBound(0) _

        Or ItemNum < List.GetLowerBound(0) Then Return "Error"

        Return List(ItemNum)

 

    End Function

End Class

 

 

2) Building a Host Application

 

- When

- Using channels

 

 

What is an application domain?

 

Application domain is like an operating system process. Application domain is used to isolate applications from one another. A single CLR operating system process contains multiple application domains.

 

What is .NET Remoting ?

 

Communication between application domains

 

Which class does the remote object has to inherit?

MarshalByRefObject - If you want to call an object of a class from outside of application domain, then the class must inherit from "MarshalByRefObject" class.

 

what are two different types of remote object creation mode in .NET

 

 

 

 

No comments:

Post a Comment