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

internal class ChannelConfigurator
{
    private string _ServerName;
    private int _PortNumber;
    private TransportProtocol _Protocol;
    private string CHANNEL_TCP_NAME = Guid.NewGuid().ToString();
    private string CHANNEL_IPC_NAME = Guid.NewGuid().ToString();


    private const int DEFAULT_PORTNUMBER = 9792;
    ///// <summary>
    ///// Defines the protocol to use when accessing Content Studio.
    ///// </summary>
    public enum TransportProtocol
    {
        /// <summary>
        /// Using TCP protocol and a certain port number.
        /// </summary>
        TCP,
        /// <summary>
        /// Using the IPC (Inter process communication) protocol for the best performance on the local machine.
        /// </summary>
        IPC
    }

    /// <summary>
    /// Creates a new configurating for access to the local machine using the TCP protocol and the default port number.
    /// </summary>
    public ChannelConfigurator()
    {
        _PortNumber = DEFAULT_PORTNUMBER;
        _Protocol = TransportProtocol.TCP;
        _ServerName = "localhost";
    }
    /// <summary>
    /// Creates a new configuration for access to the local machine using the selected protocol and port number.
    /// </summary>
    /// <param name="Protocol">The protocol to use</param>
    /// <param name="portNumber">The port number to use</param>
    public ChannelConfigurator(TransportProtocol Protocol, int PortNumber)
    {
        _PortNumber = PortNumber;
        _Protocol = Protocol;
        _ServerName = "localhost";
    }
    /// <summary>
    /// Creates a new configuration for access to the local machine using the selected protocol and the default port number.
    /// </summary>
    /// <param name="Protocol">The protocol to use</param>
    public ChannelConfigurator(TransportProtocol Protocol)
    {
        _Protocol = Protocol;
        _PortNumber = DEFAULT_PORTNUMBER;
        _ServerName = "localhost";
    }

    /// <summary>
    /// Creates a new configuration for access to a remote machine using the TCP protocol and a specific port number.
    /// </summary>
    /// <param name="ServerName">The name of the server on the network to access</param>
    /// <param name="portNumber">The port number to use</param>
    public ChannelConfigurator(string ServerName, int PortNumber)
    {
        _PortNumber = PortNumber;
        _Protocol = TransportProtocol.TCP;
        _ServerName = ServerName;
    }

    /// <summary>
    /// Creates a new configuration for access to a remote machine using the TCP protocol and the default port number.
    /// </summary>
    /// <param name="ServerName">The name of the server on the network to access</param>
    public ChannelConfigurator(string ServerName)
    {
        _PortNumber = DEFAULT_PORTNUMBER;
        _Protocol = TransportProtocol.TCP;
        _ServerName = ServerName;
    }

    /// <summary>
    /// Configures the calling process for using Content Studio with remoting.
    /// </summary>
    public void Configure()
    {
        System.Collections.IDictionary dict = new System.Collections.Hashtable();
        dict["port"] = _PortNumber;
        dict["name"] = CHANNEL_TCP_NAME;
        dict["secure"] = true;

        dict["authenticationMode"] = "Impersonate";
        dict["tokenImpersonationLevel"] = System.Security.Principal.TokenImpersonationLevel.Impersonation;

        // Set up the client channel.
        TcpClientChannel theChannel = new TcpClientChannel(dict, null);
        ChannelServices.RegisterChannel(theChannel, true);

        //Session managager must always execute on the TCP channel due to an identity spoofing bug.
        RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.SessionManager),
                                                          "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/SessionManager");
        if (_Protocol == TransportProtocol.TCP)
        {
            //ContentStudio namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.CSApplication),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/CSApplication");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.LicenseReader),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/LicenseReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.SettingManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/SettingManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.ErrorManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/ErrorManager");

            //ContentStudio.Security namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.AccessControl),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/AccessControl");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.Group),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/Group");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.GlobalTrusteeRights),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/GlobalTrusteeRights");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.TrusteeSearcher),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/TrusteeSearcher");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.User),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/User");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.UserProperties),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/UserProperties");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.WinNetworkBrowser),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/WinNetworkBrowser");

            //ContentStudio.Document namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.CategoryManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/CategoryManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.CategoryReader),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/CategoryReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentBrowser),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/DocumentBrowser");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentComponentSupport),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/DocumentComponentSupport");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocTypeManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/DocTypeManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentEncoding),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/DocumentEncoding");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/DocumentManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.PreviewManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/PreviewManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentReader),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/DocumentReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DirectiveControl),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/DirectiveControl");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentSyncronizer),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/DocumentSyncronizer");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.FolderReader),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/FolderReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.FolderSyncronizer),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/FolderSyncronizer");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.GUOID),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/GUOID");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.PublishControl),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/PublishControl");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.RevisionManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/RevisionManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Statistics),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/Statistics");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.UnitManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/UnitManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.UnitReader),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/UnitReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.VersionHistory),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/VersionHistory");

            //ContentStudio.Document.EPT namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.EPT),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/EPT");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.EPTSchema),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/EPTSchema");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.XmlIndexData),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/XmlIndexData");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.XmlIndexQuery),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/XmlIndexQuery");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.XmlIndexTags),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/XmlIndexTags");

            //ContentStudio.Document.Fulltext namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Fulltext.FulltextManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/FulltextManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Fulltext.FulltextSearch),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/FulltextSearch");

            //ContentStudio.Document.IndexedTree namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.IndexedTree.IndexedTreeManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/IndexedTreeManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.IndexedTree.IndexedTreeNavigator),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/IndexedTreeNavigator");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.IndexedTree.IndexedTreeReader),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/IndexedTreeReader");

            //ContentStudio.Document.Menu namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Menu.MenuCreator),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/MenuCreator");
            //************* (new in CS 5.2) ******************
            //ContentStudio.Document.Subscription namespace 
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Subscription.NativeSubscriptionManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/NativeSubscriptionManager");
            //************************************************
            //ContentStudio.Document.Workflow namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Workflow.Workflow),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/Workflow");
            //ContentStudio.Document.Workflow.Management namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Workflow.Management.WorkflowDefinition),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/WorkflowDefinition");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Workflow.Management.WorkflowCategoryDefinition),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/WorkflowCategoryDefinition");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Workflow.Management.WFLogManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/WFLogManager");
            //ContentStudio.EventActions namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.EventActions.EventActions),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/EventActions");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.EventActions.ServiceManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/ServiceManager");

            //ContentStudio.Notification namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Notifications.NotificationManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/NotificationManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Notifications.NotificationReader),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/NotificationReader");

            //ContentStudio.PDFServices namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.PDFServices.PDFQueueManager),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/PDFQueueManager");

            //ContentStudio.Document.MLC namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.MLC.MLC),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/MLC");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.MLC.MLCDocuments),
                                                              "tcp://" + _ServerName + ":" + _PortNumber.ToString() + "/CSServer5/MLCDocuments");
        }
        else
        {
            ChannelServices.RegisterChannel(new IpcClientChannel(CHANNEL_IPC_NAME, null), true);


            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.CSApplication),
                                                              "ipc://CS-ipc/CSServer5/CSApplication");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.ErrorManager),
                                                              "ipc://CS-ipc/CSServer5/ErrorManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.LicenseReader),
                                                              "ipc://CS-ipc/CSServer5/LicenseReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.SettingManager),
                                                              "ipc://CS-ipc/CSServer5/SettingManager");

            //ContentStudio.Security namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.AccessControl),
                                                              "ipc://CS-ipc/CSServer5/AccessControl");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.Group),
                                                              "ipc://CS-ipc/CSServer5/Group");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.GlobalTrusteeRights),
                                                              "ipc://CS-ipc/CSServer5/GlobalTrusteeRights");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.TrusteeSearcher),
                                                              "ipc://CS-ipc/CSServer5/TrusteeSearcher");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.User),
                                                              "ipc://CS-ipc/CSServer5/User");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.UserProperties),
                                                              "ipc://CS-ipc/CSServer5/UserProperties");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Security.WinNetworkBrowser),
                                                              "ipc://CS-ipc/CSServer5/WinNetworkBrowser");



            //ContentStudio.Document namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.CategoryManager),
                                                              "ipc://CS-ipc/CSServer5/CategoryManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.CategoryReader),
                                                              "ipc://CS-ipc/CSServer5/CategoryReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentBrowser),
                                                              "ipc://CS-ipc/CSServer5/DocumentBrowser");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentComponentSupport),
                                                              "ipc://CS-ipc/CSServer5/DocumentComponentSupport");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocTypeManager),
                                                              "ipc://CS-ipc/CSServer5/DocTypeManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentEncoding),
                                                              "ipc://CS-ipc/CSServer5/DocumentEncoding");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentManager),
                                                              "ipc://CS-ipc/CSServer5/DocumentManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.PreviewManager),
                                                              "ipc://CS-ipc/CSServer5/PreviewManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentReader),
                                                              "ipc://CS-ipc/CSServer5/DocumentReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DirectiveControl),
                                                              "ipc://CS-ipc/CSServer5/DirectiveControl");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.DocumentSyncronizer),
                                                              "ipc://CS-ipc/CSServer5/DocumentSyncronizer");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.FolderReader),
                                                              "ipc://CS-ipc/CSServer5/FolderReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.FolderSyncronizer),
                                                              "ipc://CS-ipc/CSServer5/FolderSyncronizer");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.GUOID),
                                                              "ipc://CS-ipc/CSServer5/GUOID");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.PublishControl),
                                                              "ipc://CS-ipc/CSServer5/PublishControl");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.RevisionManager),
                                                              "ipc://CS-ipc/CSServer5/RevisionManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Statistics),
                                                              "ipc://CS-ipc/CSServer5/Statistics");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.UnitManager),
                                                              "ipc://CS-ipc/CSServer5/UnitManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.UnitReader),
                                                              "ipc://CS-ipc/CSServer5/UnitReader");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.VersionHistory),
                                                              "ipc://CS-ipc/CSServer5/VersionHistory");
            //ContentStudio.Document.EPT namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.EPT),
                                                              "ipc://CS-ipc/CSServer5/EPT");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.EPTSchema),
                                                              "ipc://CS-ipc/CSServer5/EPTSchema");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.XmlIndexData),
                                                              "ipc://CS-ipc/CSServer5/XmlIndexData");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.XmlIndexQuery),
                                                              "ipc://CS-ipc/CSServer5/XmlIndexQuery");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.EPT.XmlIndexTags),
                                                              "ipc://CS-ipc/CSServer5/XmlIndexTags");


            //ContentStudio.Document.Fulltext namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Fulltext.FulltextManager),
                                                              "ipc://CS-ipc/CSServer5/FulltextManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Fulltext.FulltextSearch),
                                                              "ipc://CS-ipc/CSServer5/FulltextSearch");

            //ContentStudio.Document.IndexedTree namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.IndexedTree.IndexedTreeManager),
                                                              "ipc://CS-ipc/CSServer5/IndexedTreeManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.IndexedTree.IndexedTreeReader),
                                                              "ipc://CS-ipc/CSServer5/IndexedTreeReader");

            //ContentStudio.Document.Menu namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Menu.MenuCreator),
                                                              "ipc://CS-ipc/CSServer5/MenuCreator");
                                                              
            //************* (new in CS 5.2) ******************
            //ContentStudio.Document.Subscription namespace 
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Subscription.NativeSubscriptionManager),
                                                              "ipc://CS-ipc/CSServer5/NativeSubscriptionManager");
            //************************************************

            //ContentStudio.Document.Workflow namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Workflow.Workflow),
                                                              "ipc://CS-ipc/CSServer5/Workflow");
                                                              
            //ContentStudio.Document.Workflow.Management namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Workflow.Management.WorkflowDefinition),
                                                              "ipc://CS-ipc/CSServer5/WorkflowDefinition");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Workflow.Management.WorkflowCategoryDefinition),
                                                              "ipc://CS-ipc/CSServer5/WorkflowCategoryDefinition");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.Workflow.Management.WFLogManager),
                                                              "ipc://CS-ipc/CSServer5/WFLogManager");

            //ContentStudio.EventActions namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.EventActions.EventActions),
                                                              "ipc://CS-ipc/CSServer5/EventActions");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.EventActions.ServiceManager),
                                                              "ipc://CS-ipc/CSServer5/ServiceManager");

            //ContentStudio.Notification namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Notifications.NotificationManager),
                                                              "ipc://CS-ipc/CSServer5/NotificationManager");
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Notifications.NotificationReader),
                                                              "ipc://CS-ipc/CSServer5/NotificationReader");

            //ContentStudio.PDFServices namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.PDFServices.PDFQueueManager),
                                                              "ipc://CS-ipc/CSServer5/PDFQueueManager");

            //ContentStudio.Document.MLC namespace
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.MLC.MLC),
                                                              "ipc://CS-ipc/CSServer5/MLC");
            //<wellknown url="ipc://CS-ipc/CSServer5/MLCDocuments" type="ContentStudio.Document.MLC.MLCDocuments, CSServer5"/>
            RemotingConfiguration.RegisterWellKnownClientType(typeof(ContentStudio.Document.MLC.MLCDocuments),
                                                              "ipc://CS-ipc/CSServer5/MLCDocuments");
        }
    }
}