Click here to Skip to main content
15,886,258 members
Articles / Programming Languages / C#

.NET Remoting Relay Server

Rate me:
Please Sign up or sign in to vote.
4.60/5 (2 votes)
5 Jul 2006CPOL4 min read 37.8K   398   22  
An article about re-deploying remote services with the help of a relay server.
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Runtime.Remoting;

namespace RelayServer1
{
    /// <summary>
    /// 
    /// </summary>
    class Program 
    {
        static void Main(string[] args)
        {
            try
            {
                // configure the remoting infrastructure
                string configFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
                RemotingConfiguration.Configure(configFile, false);

                // simply read the application services endpoints from the config file
                string services = ConfigurationManager.AppSettings["services"];
                // create the connection objects and add them to the list of connections
                foreach(string service in services.Split(new char[] {','}))
                {
                    Uri uri = new Uri(service.Trim());
                    ChannelObjectManager.ChannelObjects.Add(uri.LocalPath, new ChannelObject(uri));

                    Console.WriteLine("{0}", uri);
                }

                Console.WriteLine("Press ENTER to exit.");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Press ENTER to exit.");
                Console.ReadLine();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
I am a consultant, trainer, software archtect/engineer, since the early 1980s, working in the greater area of Boston, MA, USA.

My work comprises the entire spectrum of software, shrink-wrapped applications, IT client-server, systems and protocol related work, compilers and operating systems, and more ....

I am currently focused on platform development for distributed computing in service oriented data centers.

Comments and Discussions