C# .NET Remoting
Hi All,
Today I’m going to show you how to make .NET Remoting, but first of all we should know what .NET Remoting is.
.NET Remoting is a mechanism for communicating between objects which are not in the same process. It is a generic system for different applications to communicate with one another. The applications can be put inside the same server, different server within the same network, or even different server within the different network.
.NET Remoting allows an application to make an object (termed remotable object) available across remoting boundaries, which includes different appdomains, processes or even different computers connected by a network.[4] The .NET Remoting runtime hosts the listener for requests to the object in the appdomain of the server application. At the client end, any requests to the remotable object are proxied by the .NET Remoting runtime over Channel objects, that encapsulate the actual transport mode, including TCP streams, HTTP streams and named pipes. As a result, by instantiating proper Channel objects, a .NET Remoting application can be made to support different communication protocols without recompiling the application. The runtime itself manages the act of serialization and marshalling of objects across the client and server appdomains.
Okay, enough for the theory, let’s begin to the practice.
First, open the the visual studio and make a new ASP.NET Empty Application
Add the interface as you will expose this function to the client side
Make the class that implement MarshalByRefObject and also the interface that you’ve created
Change the web config, so it will expose the .rem object and able to be accessed by the client
Add your application in the IIS
That’s it!, you have set up the remoting server in your IIS, now let’s make a tester to run the function that you’ve created 🙂
Let’s create a new console application
Add the reference for System.Runtime.Remoting
Include the remoting in the using section
Add the interface (should be the same with our remote server)
And then we’re ready to call our remote server, by using the Activator.GetObject() and cast it into the interface.
And yup, we did it!, the function that we made just now is being called 🙂
Nowadays, this technology is not that famous anymore since Microsoft already made a WCF remoting to do basically the same thing like what .NET Remoting does and of course with a lot of advantages 🙂
Leave a Reply