Remoting Management Console

This is a MMC Snap-in to manage a remoting host process and its configuration file. Like the COM+ catalog, the Remoting Management Console will create and administrate the host process to publish your remoting objects.

Contents

The distributed object has to be properly hosted by the application domain process such as Web Server, Console, Windows Form or Windows Service before using it. The host process requires configuration of a remoting infrastructure to enable consuming the published objects. The remoting configuration can be done programmatically or administratively. Using the config file to administrate an application deployment is a preferable and recommended way to easy mapped the logical application model to its physical implementation.

The Remoting Management Console (RMC) is an administrative tool to create and configure a remoting host process built as a windows service. The console has a mechanism to create a windows service on the fly including its configuration file. Using the properly snap-in nodes the config file can be administratively finalized based on the application requirements before the host process starts. On the other hand, the RMC is also very useful tool for administrating (tuning phase) already deployed the distributed application modifying the contents of the host process config files. This article describes a usage and implementation of the Remoting Management Console tool.

Using the windows service to host remoting objects is straightforward. The standard boilerplate generated by .Net wizard has been extended for a remoting registration and un-registration parts like it's shown in the following code snippet:

When the windows service receives a Start command, the OnStart action is invoked to perform a remoting configuration from the config file. On the other side, the OnStop action will clean-up all listeners hosted by this service included their worker threads.

The host process (windows service) must have a unique name registered on the local machine. The RMC has a mechanism to create a unique host process on the fly based on the application requirements. Practically, the host process template source is modified in the variable places before its compiling (see Implementation)

Once the host process has been created, the RMC will control its state such as start, stop and restart using the MMC environment.

In the case of the existing non-installed host process, the RMC has a drag&drop capability making its entry to the catalog. The other hand, the already installed host processes are scanned and added into the snap-in. Notice that the host process need to have an implementation of the derived Installer class attributed with RunInstaller(true) to make its installation rsp. un-installation service automatically.

The initiate config file image is generated from the template HostProcessTemplate.exe.config file located in the %windir%/system32 folder. It's very easy to replace it for another one with custom pre-built common configuration. The RMC has many features for administrating this config file using the snip-in layout.

The RMC is a stateless snap-in in the MMC environment. Each node is updated on the runtime based on the host process status and contents of the config file. Thanks for MMCLib library developed by http://www.ironringsoftware.com to make my life easy to handle a unmanaged MMC code. I made some slightly modification of the MMCLib for my needs, that's why I included its source in my solution. Basically, the MMCLib handles a snap-in such as creating nodes and processing their events. The following picture show that:

Based on the menu selection, for instance: New -> Remote Object, the snap-in delegates call to the properly event handler (OnNewTask) to perform the specific action. In this case, the windows form is popup to enter necessary attributes requested by the remoting service section in the config file. After pressing the Apply button on the form, the config file is updated and snap-in is notified via its handler - OnUser. This scenario is repeated mostly for all node's activities.

The RMC requires to be installed by the RemotingManagementConsole.msi file. The windows installer will perform all necessary tasks such as RMC snap-in, MMCLib.dll and MMCFormsShim.dll registration included creating its desktop folder. Opening this folder and clicking on the RemotingManagementConsole.msc icon, the Remoting Management Console will show up with the snap-in of all the installed host processes on your machine. The screen snippet has been shown in the previously chapter.

Let me suppose that we have a remote object and its consumer ready to deploy them. Before the actually work, the remoting object is necessary be hosted and published by windows service host process.

What we need to do?

create a windows host process

publish a remoting object in the remoting service tag

create a channel to listen an incoming remoting messages (IMessages)

Additionally, based on the application requirements:

adding server Sinks (formatter, provider)

creating an appSettings for configuration purposes (key/value pairs)

creating specific config sections

When the configuration process is done, the host process is ready to start. Using the Event Log we can see a process of the remoting configuration. Based on the detail event log message is easy to figure out which attribute in the config file caused the problem.

Now, if we know what the remoting configuration needs, let handle this task do it by RMC. Here are its steps:

Step A. Create a new host process

Select the Remoting Host Processes node in the snap-in area

Right-click on the node

Select New and click Process

The following Form dialog will show-up

Change the Name properties, for instance: HostProcess_Sample

Press button CREATE

Now we have a host process installed as a windows service and initiate image of the host process config file. The RMC snap-in created automatically static nodes for this host process:

lifetime

RemoteObjects

Channels

appSettings

configSections

The above nodes represent xml sections in the host process remoting config file. For the next step we are going to administrate them based on the application requirements.

Step B. Publishing Remote Object

Select the RemoteObjects node in the HostProcess_Sample root

Right-click on the node

Select New and click Remote Object

The following Form dialog will show-up

Populate all attributes on the Form

Press button APPLY

The other, shortcut way (skipping the steps 1-3) is to use a Drag&Drop feature when the remote object exist. The following steps explain that:

Drag the assembly of the Remote Object, which you what to publish it from its folder

When your application using a standard channel, for instance: tcp, enter the port number (must be unique on the machine) and leave empty the other attributes.

The channel can be configured using the already registered channels (machine.config and host process config) or typing its type in this element. See the checkBox and comboBox features.

On the bottom of the Form is displayed the finally element for config file.

The textBox More can be used to add any specific attributes using the name/value pair, for instance: priority="1" myProperty="myValue"

Now, we have a basic configuration of the host process for our remote object. Of course, we can continue to make more advance configuration. I assume you have a knowledge of the remoting configuration and MMC to allow you easy figure out usage of the others nodes in the RMC snap-in.

Let's continue with our basic configuration. As the next step is to start the host process.

Step D. Start Host Process

Select the HostProcess_Sample node in the snap-in area

Right-click on the node

Select All Task and click Start

The Form dialog will show the progress of the starting process

Check the Host Process result view (right panel) for the Event Log Messages

To Stop or Restart the host process follow the same steps as for Start one.

Refreshing snap-in

Each static node in the snap-in has a Refresh menu item to perform a updating result view and snap-in at the selected level. There is one special Refresh at the snap-in root. In this case the RMC is invoking the scanner of the installed host processes (windows services) on the local machine and refreshing a completely snap-in. You can use also the key F5 to invoke the refresh task.

The template requires to customize its entries such as SERVICE_NAME, SERVICE_START, SERVICE_DESCRIPTION and SERVICE_TRAYICON to finalize the host process code. This task is performed using the string.replace function.

As I mentioned early, the RemotingManagement contains many forms and user controls to handle a particular snap-in node. Basically, their implementations has the same design pattern based on the event driven mechanism. You can see it in the following code snippet how the lifetime node handle it:

As you can see this test solution doesn't have a host server project, that's why the RMC comes to create one. The client is a simple windows form to ask a remote object for the specific section in the config file. Here is its screen shot:

Note that the msi file will install also this test sample, so it's easy to click for the WindowsFormClient icon in the RMC desktop folder to start test it.

In this article I described a tool hosted by MMC that allows to administrate any remoting object without writing its host process. The Remoting Management Console tool will create automatically a remoting host process including its configuration file. The RMC becomes very useful tool especially during the deployment phase, where a configuration of the distributed objects need to be tuned based on the deployment environment.

The release version with features such as remoting probe and enterprise support to allow administrate the remoting host process remotely will give you a powerful administration tool for your product.

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.