Click here to Skip to main content
15,885,141 members
Articles / Programming Languages / C#

Pluggable Remote Object Hosting

Rate me:
Please Sign up or sign in to vote.
3.17/5 (6 votes)
11 Nov 20033 min read 44K   1.3K   37  
This article presents a Pluggable mechanism for the identification and hosting of .NET Remote objects.
using System;
using System.Collections;

using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

using System.IO;

namespace Boland.Plugin
{

	class RemoteHostingApp
	{
		[STAThread]
		static void Main(string[] args)
		{
			try
			{
				Console.Write("Remote Hosting Application Started ");
				Console.Write(DateTime.Now.ToLongDateString() + ":");
				Console.WriteLine(DateTime.Now.ToLongTimeString());

				Console.WriteLine("About to deploy standard Remote Objects");
				RemotingConfiguration.Configure("RemoteHostingApp.exe.config");
				Console.WriteLine("Standard Remote Objects deployed");
				
				RemotePluginManager pluginManager =
					new RemotePluginManager();
				Console.WriteLine("About to deploy Pluggable Remote Objects");
				pluginManager.RegisterPlugins();
				Console.WriteLine("Pluggable Remote Objects deployed");

				ShowWellKnownServices();

				System.Console.Write("Hit any key to exit: ");
				System.Console.ReadLine();

				Console.Write("Remote Hosting Application Stopped ");
				Console.Write(DateTime.Now.ToLongDateString() + ":");
				Console.WriteLine(DateTime.Now.ToLongTimeString());
			}
			catch(Exception e)
			{
				Console.WriteLine(e);
			}
		}

		protected static void ShowWellKnownServices()
		{
			Console.WriteLine("--------------Well known services--------------");
			WellKnownServiceTypeEntry[] entries = 
				RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
			foreach(WellKnownServiceTypeEntry entry in entries)
			{
				Console.WriteLine("Assembly: " + entry.AssemblyName);
				Console.WriteLine("Mode: " + entry.Mode);
				Console.WriteLine("URI: " + entry.ObjectUri);
				Console.WriteLine("Type: " + entry.TypeName);
			}
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions