ArcGIS Simple Server Object Extension
ArcGIS_Simple_Server_Object_Extension_CSharp\RegisterSOE\Program.cs
// Copyright 2009 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See the use restrictions.
// 


using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.Server;
using ESRI.ArcGIS.ADF.Connection.AGS;

namespace RegisterSOE
{
    class Program
    {
        static void Main(string[] args)
        {
            // Must run as an user in the agsadmin group on the SOM
            AGSServerConnection gisconnection = new AGSServerConnection();
            gisconnection.Host = "localhost";
            gisconnection.Connect();
            IServerObjectAdmin2 soa = (IServerObjectAdmin2) gisconnection.ServerObjectAdmin;
            IServerObjectExtensionType2 soet = (IServerObjectExtensionType2) soa.CreateExtensionType();

            soet.CLSID = "SimpleSOE_CSharp.UtilSOE_CSharp";
            soet.Description = "Simple Server Object Extension CSharp";
            soet.Name = "SimpleSOE_CSharp";
            soet.DisplayName = "Simple SOE CSharp";

            // To delete SOE
            //soa.DeleteExtensionType("MapServer", soet.Name);
            //Console.WriteLine("UNRegistered SOE with ArcGIS Server");

            // To add SOE
            soa.AddExtensionType("MapServer", soet);
            Console.WriteLine("Registered SOE with ArcGIS Server");
            
            Console.ReadLine();
        }
    }
}