Database Search Solution
(New Version) Search Control
Free ASP.NET Controls
ASP.NET Media Player Control
Flash Video Player Control
ASP.NET Telecommute Jobs
Free IP Location Lookup
Test .Net Regular Expressions
CSS/Table/DIV Page Layouts
Article Sites Master List
.NET Windows Forms
General .NET Framework
Accepting Credit Cards
.NET Remoting Tutorial
Different applications can communicate with one another through a .NET Remoting. This is accomplished through remote processes, which the .NET objects can make use of. It is to note that while using .net remoting, it is not essential that your applications which intend to communicate are located on the same computer, they can work with different computers on the same network or across different networks.
.NET Remoting along with DCOM and web services are a part of the distributed applications. .NET Remoting is actually communication between server and client objects using object references. It is to note that to use .NET Remoting, a client needs to be built using .NET.
Difference between ASP.NET Web services and .NET Remoting
1. Web services can only be accessed over HTTP whereas .NET Remoting can be accessed over various protocols like TCP, HTTP etc.
2. Web services operate in a stateless environment since its HTTP, a stateless protocol whereas .NET remoting support state management (as in through Singleton and SingleCall objects)
3. Web services are more reliable than .NET Remoting.
4. Web services are easy to create and use while .NET Remoting are complex to be created.
5. Web services support heterogeneous environments i.e. support interoperability across platforms, on the other hand .NET remoting requires client to be built using .NET, thus it does'nt support heterogeneous environment.
6. Web Services support datatypes defined in the XSD type system while .NET remoting provides support for rich type system using binary communication.
Channels and Remote Object
Now that you know what exactly .NET Remoting is, we will study on working with how this is implemented. First requirement is a Channel, i.e. the medium through the which the messages would be transferred. The remote objects are to communicate with one another and channels do this transport job of communication. The two existing channels are HttpChannel and TCPChannel.
We have three types of that can be used as a Remote Object. They are:
Implementing .NET Remoting
To accomplish this, we will need:
Creating a Remote Object
To create an object, we must declare a remotable class. It is to note that the class has to inherit the MarshalByRefObject. To do this, Open a new project of Class library type. and write the following code, to calculate product of 2 numbers:
Now build the project and you will have a DLL generated.
Now to create object of this class remotely, we must build a host application which registers our created class and a channel for remoting. Create it in the same directory where you have addsubs.dll. And compile it to dll our code will be using host.exe.config, so we will need to create it too in the same directory as host.exe. The host.exe.config is as follows:
A Client application domain
Our application must reside in the client application domain to use .NET Remoting system. For this we will create a client.cs and client.exe.config, as we created for the host domain.
Save the above as client.exe.config. Keep a note on the directory where you save these files. You should save the client.exe and the config file in the same directory.
To test your application run the client.exe from the command prompt.
It is to note that creating a .config file is not essential, you have an alternative method to include the config settings in your .cs file itself as ahown below. Remember to include the following two namespaces.
Next, include these two lines of code in the host.cs and client.cs files along with the other functionality as discussed above:
HttpChannel channel = new TcpChannel(8989);
Tutorial toolbar: Tell A Friend | Add to favorites | Feedback |
comments powered by Disqus