예제 #1
0
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Please specify the nameservice url either as ior or corbaloc");
            }
            string nameServiceUrl = args[0];

            // register the channel
            int         port = 8087;
            IiopChannel chan = new IiopChannel(port);

            ChannelServices.RegisterChannel(chan, false);

            AdderImpl adder     = new AdderImpl();
            string    objectURI = "adder";

            RemotingServices.Marshal(adder, objectURI);

            // publish the adder with an external name service
            NamingContext nameService = (NamingContext)RemotingServices.Connect(typeof(NamingContext),
                                                                                nameServiceUrl);

            NameComponent[] name = new NameComponent[] { new NameComponent("adder") };
            nameService.bind(name, adder);
            Console.WriteLine("server running");
            Console.ReadLine();

            // unpublish with external name service
            nameService.unbind(name);
        }
예제 #2
0
    protected NameComponent[] GetNameComponent(System.Object obj, string objectName)
    {
        NameComponent[] nc = new
                             NameComponent[] { new NameComponent("cargo", "context"), new NameComponent(objectName, "object") };

        try
        {
            if (obj.GetType().FullName.Equals("XI_Impl"))
            {
                m_NameService.bind(nc, (XI_Impl)obj);
            }
        }
        catch (AbstractCORBASystemException ex)
        {
            MessageBox.Show("Unable to find XI Object\n" + ex.Message);
            return(null);
        }
        catch (System.Exception e)
        {
            string str = e.Message;

            try
            {
                if (obj.GetType().FullName.Equals("XI_Impl"))
                {
                    m_NameService.rebind(nc, (XI_Impl)obj);
                }
            }
            catch (System.Exception e1)
            {
                MessageBox.Show("Rebinding XI Failed\n" + e1.Message);
            }
        }

        return(nc);
    }