コード例 #1
0
        static void Main(string[] args)
        {
            try
            {
                System.Console.WriteLine("Configuring channel...");
                IpcClientChannel clientChannel = new IpcClientChannel();
                ChannelServices.RegisterChannel(clientChannel);

                System.Console.WriteLine("Configuring remote object...");
                IRemotedType TheObject = (IRemotedType)Activator.GetObject(
                    typeof(RemotedType.IRemotedType),
                    "ipc://MyIpcChannel/MyObject.rem");

                System.Console.WriteLine("Please enter data, 'exit' quits the program!");
                string input = string.Empty;
                do
                {
                    System.Console.Write(">> Enter text: ");
                    input = System.Console.ReadLine();
                    if (string.Compare(input, "exit", true) != 0)
                    {
                        System.Console.Write(">> Enter number: ");
                        int c = Int32.Parse(System.Console.ReadLine());
                        TheObject.DoCall(input, 2);
                    }
                } while (string.Compare(input, "exit", true) != 0);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception while processing contents: " + ex.Message);
                System.Console.ReadLine();
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            try
            {
                Dictionary <string, string> dict = new Dictionary <string, string>();
                dict.Add("impersonationLevel", "Identify");
                dict.Add("encryption", "EncryptAndSign");

                System.Console.WriteLine("Configuring channel...");
                TcpClientChannel clientChannel = new TcpClientChannel(dict, null);
                ChannelServices.RegisterChannel(clientChannel);

                System.Console.WriteLine("Configuring remote object...");
                IRemotedType TheObject = (IRemotedType)Activator.GetObject(
                    typeof(RemotedType.IRemotedType),
                    "tcp://localhost:9001/MyObject.rem");

                System.Console.WriteLine("Please enter data, 'exit' quits the program!");
                int    c     = 0;
                string input = string.Empty;
                do
                {
                    System.Console.Write("Enter message: ");
                    input = System.Console.ReadLine();
                    if (string.Compare(input, "exit", true) != 0)
                    {
                        System.Console.Write("Enter counter: ");
                        c = Int32.Parse(System.Console.ReadLine());

                        TheObject.DoCall(input, c);
                    }
                } while (string.Compare(input, "exit", true) != 0);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception while processing contents: " + ex.Message);
                System.Console.ReadLine();
            }
        }