Example #1
0
        public static SC.Interfaces.IRoot GetRoot(string Host, string Username, string Password)
        {
            string channelname = Host + ":" + Username;

            if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel(channelname) == null)
            {
                System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider soapFormatter = new System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider();
                SC.Remoting.ClientEncryptionSinkProvider     encrProvider = new SC.Remoting.ClientEncryptionSinkProvider();
                SC.Remoting.ClientAuthenticationSinkProvider authProvider = new SC.Remoting.ClientAuthenticationSinkProvider(Username, Password);

                soapFormatter.Next = authProvider;
                authProvider.Next  = encrProvider;

                Dictionary <string, string> props = new Dictionary <string, string>();
                props["name"]     = channelname;
                props["priority"] = System.Threading.Interlocked.Increment(ref priority).ToString();

                System.Runtime.Remoting.Channels.Http.HttpClientChannel channel = new System.Runtime.Remoting.Channels.Http.HttpClientChannel(props, soapFormatter);
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
            }
            SC.Interfaces.IRoot root = System.Runtime.Remoting.RemotingServices.Connect(typeof(SC.Interfaces.IRoot), "http://" + Username + "@" + Host + "/ServerChecker4Root") as SC.Interfaces.IRoot;

            //SC.Interfaces.IRoot root = Activator.GetObject(typeof(SC.Interfaces.IRoot), "http://" + Host + "/ServerChecker4Root") as SC.Interfaces.IRoot;
            return(root);
        }
        public static SC.Interfaces.IRoot GetRoot(string Host, string Username, string Password)
        {
            string channelname = Host + ":" + Username;
            if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel(channelname) == null)
            {
                System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider soapFormatter = new System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider();
                SC.Remoting.ClientEncryptionSinkProvider encrProvider = new SC.Remoting.ClientEncryptionSinkProvider();
                SC.Remoting.ClientAuthenticationSinkProvider authProvider = new SC.Remoting.ClientAuthenticationSinkProvider(Username, Password);

                soapFormatter.Next = authProvider;
                                     authProvider.Next = encrProvider;

                Dictionary<string, string> props = new Dictionary<string, string>();
                props["name"] = channelname;
                props["priority"] = System.Threading.Interlocked.Increment(ref priority).ToString();

                System.Runtime.Remoting.Channels.Http.HttpClientChannel channel = new System.Runtime.Remoting.Channels.Http.HttpClientChannel(props, soapFormatter);
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
            }
            SC.Interfaces.IRoot root = System.Runtime.Remoting.RemotingServices.Connect(typeof(SC.Interfaces.IRoot), "http://" + Username + "@" + Host + "/ServerChecker4Root") as SC.Interfaces.IRoot;

            //SC.Interfaces.IRoot root = Activator.GetObject(typeof(SC.Interfaces.IRoot), "http://" + Host + "/ServerChecker4Root") as SC.Interfaces.IRoot;
            return root;
        }