Exemplo n.º 1
0
        public void MainFunc()
        {
            // Создаём каналы
            IpcChannel channel1 = new IpcChannel();
            IpcChannel channel2 = new IpcChannel();
            IpcChannel channel3 = new IpcChannel();

            // Регистрируем канал.
            System.Runtime.Remoting.Channels.ChannelServices.
            RegisterChannel(channel1, false);

            // Регистрируем клиентские удалённые обьекты.
            System.Runtime.Remoting.WellKnownClientTypeEntry remoteType1 =
                new System.Runtime.Remoting.WellKnownClientTypeEntry(
                    typeof(ClassLibrary1.Class1),
                    "ipc://localhost:9090/RemoteObject1.rem");

            System.Runtime.Remoting.WellKnownClientTypeEntry remoteType2 =
                new System.Runtime.Remoting.WellKnownClientTypeEntry(
                    typeof(ClassLibrary2.Class2),
                    "ipc://localhost:9090/RemoteObject2.rem");

            System.Runtime.Remoting.WellKnownClientTypeEntry remoteType3 =
                new System.Runtime.Remoting.WellKnownClientTypeEntry(
                    typeof(ClassLibrary3.Class3),
                    "ipc://localhost:9090/RemoteObject3.rem");

            System.Runtime.Remoting.RemotingConfiguration.
            RegisterWellKnownClientType(remoteType1);
            System.Runtime.Remoting.RemotingConfiguration.
            RegisterWellKnownClientType(remoteType2);
            System.Runtime.Remoting.RemotingConfiguration.
            RegisterWellKnownClientType(remoteType3);

            // Создаём приемники сообщений
            string objectUri;

            System.Runtime.Remoting.Messaging.IMessageSink messageSink1 =
                channel1.CreateMessageSink(
                    "ipc://localhost:9090/RemoteObject1.rem", null,
                    out objectUri);
            System.Runtime.Remoting.Messaging.IMessageSink messageSink2 =
                channel2.CreateMessageSink(
                    "ipc://localhost:9090/RemoteObject2.rem", null,
                    out objectUri);
            System.Runtime.Remoting.Messaging.IMessageSink messageSink3 =
                channel3.CreateMessageSink(
                    "ipc://localhost:9090/RemoteObject3.rem", null,
                    out objectUri);

            // Создание экземпляра удаленного объекта
            service1 = new ClassLibrary1.Class1();
            service2 = new ClassLibrary2.Class2();
            service3 = new ClassLibrary3.Class3();

            return;
        }
Exemplo n.º 2
0
 private void BtnExecuteClass2_Click(object sender, EventArgs e)
 {
     try
     {
         ClassLibrary2.Class2 obj = new ClassLibrary2.Class2();
         WriteLog(obj.GetName());
     }
     catch (Exception ex)
     {
         WriteExceptionLog(ex);
     }
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Type t = Type.GetType("ClassLibrary1.Class1", false);

            if (t != null)
            {
                Console.WriteLine(t.Name);
            }
            else
            {
                Console.WriteLine("Тип не найден");
            }


            ClassLibrary2.Class2 c2 = new ClassLibrary2.Class2();
            Console.WriteLine(c2.ToString());

            Console.ReadLine();
        }