示例#1
0
        public static bool CreateChannel <T>(string specName)
        {
            string FullName = typeof(T).FullName;

            string[] NameArr   = FullName.Split('.');
            string   ClassName = NameArr[NameArr.Length - 1];

            if (specName != null)
            {
                ClassName = specName;
            }
            string ChannelName = "WolfIPC_Channel";

            try
            {
                ToLog("IPC服务端日志", "检查是否是管理员", WinComminuteClass.IsRoot().ToString());
                ToLog("IPC服务端日志", "正在初始化通道", ChannelName);
                if (!channels.ContainsKey(ChannelName))
                {
                    ToLog("IPC服务端日志", "注册通道", ChannelName);
                    Hashtable ht = new Hashtable();
                    ht["portname"]        = ChannelName;
                    ht["name"]            = "ipc";
                    ht["authorizedGroup"] = "everyone";
                    IpcServerChannel channel = new IpcServerChannel(ht, null);
                    ChannelServices.RegisterChannel(channel, true);
                    channels.Add(ChannelName, channel);
                }
                ToLog("IPC服务端日志", "正在注册通道绑定数据类型", ClassName);
                //IpcServerChannel channel = new IpcServerChannel(string.Format("WolfIPC_Channel"));
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(T), ClassName, WellKnownObjectMode.SingleCall);
                //RemoteCommClass<T> obj = new RemoteCommClass<T>();
                ToLog("IPC服务端日志", "绑定数据类型完毕", ClassName);
            }
            catch (Exception e)
            {
                ToLog(string.Format("IPC服务端日志", "初始化通道[{0}]失败", FullName), e.Message);
                return(false);
            }
            return(true);
        }
示例#2
0
        static void Main(string[] args)
        {
            //Configuracion de la comunicacion remota del
            RemotingConfiguration.Configure("ClienteSAO.exe.config");
            //llamada al metodo MostarTodosLosDatos de la clase utilidades
            Utilidades.MostrarTodosLosDatos();
            //instancia de un objeto tipo string
            string resultado;

            //llamada al metodo EsperarParaTerminar de la clase Log
            Log.EsperarParaTerminar("1) Presione ENTER para crear el objeto remoto...");
            //Instancia e inicializacion de un objeto tipo ComponenteCAO
            ComponenteSAOSC.ComponenteSAOSC miComponente = new ComponenteSAOSC.ComponenteSAOSC();
            //llamada al metodo Imprimir donde se muestra un mensaje, indica si es un objeto proxy real o transparente
            Log.Imprimir("miComponente ha sido creado. Es Proxy? {0}", (RemotingServices.IsTransparentProxy(miComponente) ? "SI" : "NO"));
            //llamada al metodo EsperarParaTerminar de la clase Log
            Log.EsperarParaTerminar("2) Presione ENTER para usar el primer metodo...");
            //invocacion del metodo PrimeraLlamada() de la clase ComponenteCAO el cual se guarda en la variable resultado tipo string
            resultado = miComponente.PrimeraLlamada();
            Log.Imprimir("miComponente.PrimeraLlamada() retorno: {0}", resultado);
            //llamada al metodo EsperarParaTerminar de la clase Log
            Log.EsperarParaTerminar("3) Presione ENTER para usar el segundo metodo...");
            //invocacion del metodo SegundaLlamada() de la clase ComponenteCAO el cual se guarda en la variable resultado tipo string
            resultado = miComponente.SegundaLlamada();
            Log.Imprimir("miComponente.SegundaLlamada() retorno: {0}", resultado);
            //llamada al metodo EsperarParaTerminar de la clase Log
            Log.EsperarParaTerminar("4) Presione ENTER para crear un nuevo objeto remoto...");
            //Instancia e inicializacion de un objeto tipo ComponenteCAO
            ComponenteSAOSC.ComponenteSAOSC otroComponente = new ComponenteSAOSC.ComponenteSAOSC();
            //llamada al metodo Imprimir donde se muestra un mensaje, indica si es un objeto proxy real o transparente
            Log.Imprimir("otroComponente ha sido creado. Es Proxy? {0}", (RemotingServices.IsTransparentProxy(otroComponente) ? "SI" : "NO"));
            //llamada al metodo EsperarParaTerminar de la clase Log
            Log.EsperarParaTerminar("5) Presione ENTER para usar el primer metodo...");
            //invocacion del metodo PrimeraLlamada() de la clase ComponenteCAO el cual se guarda en la variable resultado tipo string
            resultado = otroComponente.PrimeraLlamada();
            Log.Imprimir("otroComponente.PrimeraLlamada() retorno: {0}", resultado);
            //llamada al metodo EsperarParaTerminar de la clase Log
            Log.EsperarParaTerminar("Presione ENTER para salir...");
            //Evita que se cierre el servidor
            Console.ReadLine();
        }
示例#3
0
    public static void Main(string[] args)
    {
        //<snippet21>
        // Create the server channel.
        TcpServerChannel channel = new TcpServerChannel(
            "Server Channel", 9090, null);

        //</snippet21>

        // Register the server channel.
        ChannelServices.RegisterChannel(channel);

        // Expose an object for remote calls.
        RemotingConfiguration.RegisterWellKnownServiceType(
            typeof(RemoteObject), "RemoteObject.rem",
            WellKnownObjectMode.Singleton);

        //<snippet22>
        // Display the channel's URI.
        Console.WriteLine("The channel URI is {0}.",
                          channel.GetChannelUri());
        //</snippet22>

        //<snippet23>
        // Parse the channel's URI.
        string[] urls = channel.GetUrlsForUri("RemoteObject.rem");
        if (urls.Length > 0)
        {
            string objectUrl = urls[0];
            string objectUri;
            string channelUri = channel.Parse(objectUrl, out objectUri);
            Console.WriteLine("The object URI is {0}.", objectUri);
            Console.WriteLine("The channel URI is {0}.", channelUri);
            Console.WriteLine("The object URL is {0}.", objectUrl);
        }
        //</snippet23>

        // Wait for the user prompt.
        Console.WriteLine("Press ENTER to exit the server.");
        Console.ReadLine();
    }
示例#4
0
    public static void Main()
    {
        GenericIdentity  ident = new GenericIdentity("Bob");
        GenericPrincipal prpal = new GenericPrincipal(ident,
                                                      new string[] { "Level1" });
        LogicalCallContextData data = new LogicalCallContextData(prpal);

        //Enter data into the CallContext
        CallContext.SetData("test data", data);

        Console.WriteLine(data.numOfAccesses);

        ChannelServices.RegisterChannel(new TcpChannel());

        RemotingConfiguration.RegisterActivatedClientType(typeof(HelloServiceClass),
                                                          "tcp://localhost:8082");

        HelloServiceClass service = new HelloServiceClass();

        if (service == null)
        {
            Console.WriteLine("Could not locate server.");
            return;
        }

        // call remote method
        Console.WriteLine();
        Console.WriteLine("Calling remote object");
        Console.WriteLine(service.HelloMethod("Caveman"));
        Console.WriteLine(service.HelloMethod("Spaceman"));
        Console.WriteLine(service.HelloMethod("Bob"));
        Console.WriteLine("Finished remote object call");
        Console.WriteLine();

        //Extract the returned data from the call context
        LogicalCallContextData returnedData =
            (LogicalCallContextData)CallContext.GetData("test data");

        Console.WriteLine(data.numOfAccesses);
        Console.WriteLine(returnedData.numOfAccesses);
    }
        static void Main(string[] args)
        {
            String filename = "AliceClient.exe.config";

            RemotingConfiguration.Configure(filename);

            //Create Bob remotely
            Bob.Bob bob = new Bob.Bob();
            System.Console.Out.WriteLine("Bob created remotely");

            //Create Locally Alice
            Alice.Alice alice = new Alice.Alice();
            System.Console.Out.WriteLine("Alice created locally");

            //let Alice create the session key and envelope it
            byte[] digitalEnvelope = alice.Envelope();
            System.Console.Out.WriteLine("Alice create envelope :" + digitalEnvelope);

            //send the enveloped session key to Bob
            bob.Envelope(digitalEnvelope);
            System.Console.Out.WriteLine("Digital Envelope send to Bob\n\n");


            System.Console.Out.WriteLine("Enter the message that alice should send to Bob.");
            System.Console.Out.WriteLine("To stop sending any mesasge just press <enter>:");
            do
            {
                System.Console.Out.Write("Message :");
                string plaintext = Console.ReadLine();
                if (plaintext.Length == 0)
                {
                    break;
                }

                //Alice will encrypt it with the session key that it exchanged with Bob
                byte[] ciphertextbyte = alice.Message(plaintext);

                //send the cipher text to Bob
                bob.Message(ciphertextbyte);
            } while (true);
        }
示例#6
0
        public bool GetServerObject <T>(string url) where T : MarshalByRefObject
        {
            string FullName  = typeof(T).Name;
            string ClassName = FullName.Split('\'')[0];

            //T ret = default(T);
            try
            {
                //string ChannleName = string.Format("ipc://IPC_{0}/{1}", specName, ClassName);
                string ChannleName = url;
                ToLog("IPC客户端日志", "指定客户端通道URL", ChannleName);
                string           cname = string.Format("{0}", ClassName);
                IpcClientChannel icc   = null;// new IpcClientChannel(cname,null);
                //ChannelServices.RegisterChannel(icc, false);
                //if (ChannelServices.GetChannel(icc.ChannelName) == null)
                if (!iccs.ContainsKey(cname))
                {
                    icc = new IpcClientChannel();
                    ToLog("IPC客户端日志", "注册客户端通道", icc.ChannelName);
                    ChannelServices.RegisterChannel(icc, false);
                    //WellKnownClientTypeEntry remotEntry = new WellKnownClientTypeEntry(typeof(T), ChannleName);
                    RemotingConfiguration.RegisterWellKnownClientType(typeof(T), ChannleName);
                    iccs.Add(cname, icc);
                }
                else
                {
                    ToLog("IPC客户端日志", "存在客户端通道", cname);
                    icc = iccs[cname];
                }

                ToLog("IPC客户端日志", "所有可通道", getAllChannelsInfo());
                return(true);
            }
            catch (Exception e)
            {
                ToLog("IPC客户端日志", "访问通道失败", string.Format("{0}:{1}", e.Message, e.StackTrace));

                return(false);
            }
            //return ret; //返回一个空内容的壳,需要调用GetRemoteData实际调取数据
        }
示例#7
0
        static void Main(string[] args)
        {
            if ((args.Length == 2) && (args[0].Equals("-iphonepackager")))
            {
                try
                {
                    // We were run as a 'child' process, quit when our 'parent' process exits
                    // There is no parent-child relationship WRT windows, it's self-imposed.
                    int ParentPID = int.Parse(args[1]);

                    IpcServerChannel Channel = new IpcServerChannel("iPhonePackager");
                    ChannelServices.RegisterChannel(Channel, false);
                    RemotingConfiguration.RegisterWellKnownServiceType(typeof(DeploymentImplementation), "DeploymentServer_PID" + ParentPID.ToString(), WellKnownObjectMode.Singleton);

                    Process ParentProcess = Process.GetProcessById(ParentPID);
                    while (!ParentProcess.HasExited)
                    {
                        System.Threading.Thread.Sleep(1000);
                    }
                }
                catch (System.Exception)
                {
                }
            }
            else
            {
                // Run directly by some intrepid explorer
                Console.WriteLine("Note: This program should only be started by iPhonePackager");
                Console.WriteLine("  This program cannot be used on it's own.");


                DeploymentImplementation Deployer = new DeploymentImplementation();
                var DeviceList = Deployer.EnumerateConnectedDevices();
                foreach (var Device in DeviceList)
                {
                    Console.WriteLine("  - Found device named {0} of type {1} with UDID {2}", Device.DeviceName, Device.DeviceType, Device.UDID);
                }

                Console.WriteLine("Exiting.");
            }
        }
示例#8
0
        static void Main(string[] args)
        {
            bool  createdNew = false;
            Mutex instance   = new Mutex(true, Process.GetCurrentProcess().MainModule.FileName.Replace("\\", "/"), out createdNew);

            if (createdNew)
            {
                var remotingConfigPath = AppDomain.CurrentDomain.BaseDirectory + "RemotingConfig.xml";
                var updatePath         = AppDomain.CurrentDomain.BaseDirectory + "AutoUpdate.exe";
                if (args.Length == 0)
                {
                    if (File.Exists(updatePath))
                    {
                        System.Diagnostics.Process.Start(updatePath, "LEDDisplay.exe");
                        return;
                    }
                }
                else if (args[0] == "AutoUpdate")
                {
                    var newUpdatePath = AppDomain.CurrentDomain.BaseDirectory + "AutoUpdate.exe.tmp";
                    if (File.Exists(newUpdatePath))
                    {
                        File.Delete(updatePath);
                        File.Move(newUpdatePath, updatePath);
                    }
                    //有新的更新内容
                    if (bool.Parse(args[1]))
                    {
                        var config = File.ReadAllText(remotingConfigPath).Replace("0.0.0.0:0000", ConfigurationManager.AppSettings["RemotingConfig"]);
                        File.WriteAllText(remotingConfigPath, config);
                    }
                }
                RemotingConfiguration.Configure(remotingConfigPath, false);
                //if (!Validate.Check())
                //    return;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FrmMain());
                instance.ReleaseMutex();
            }
        }
示例#9
0
        static void Main()
        {
            RemotingConfiguration.Configure("SponsorClient.exe.config", false);

            String idClient = "id" + Math.Abs(DateTime.Now.GetHashCode() / 1000000);

            Console.WriteLine("Client started, {0}", idClient);

            MyClientActivatedObject myClientActivated;

            try {
                myClientActivated = new MyClientActivatedObject();
            }
            catch (WebException) {
                Console.WriteLine("Ошибка при подключении к серверу.");
                Console.ReadLine();
                return;
            }

            myClientActivated.SetId(idClient);

            myClientActivated.MyRegistration(new CaoClientSponsor("CAO " + idClient));
            myClientActivated.Run();

            MySingleton mySingleton;

            try {
                mySingleton = new MySingleton();
            }
            catch (WebException) {
                Console.WriteLine("Ошибка при подключении к серверу.");
                Console.ReadLine();
                return;
            }

            mySingleton.MyRegistration(new SingletonClientSponsor("Singleton"));
            mySingleton.Run();

            Console.WriteLine("Press Enter to end ...");
            Console.ReadLine();
        }
示例#10
0
        static void Main(string[] args)
        {
            String filename = "client.exe.config";

            RemotingConfiguration.Configure(filename);

            Console.WriteLine("q to exit, number, number to call mathod, ,a at the end for async. call, Enter to call remote object");

            string s;

            try{
                while ((s = Console.ReadLine()) != "q")
                {
                    RemoteObject obj = new RemoteObject();
                    int          res;
                    string[]     arr = s.Split(new char[] { ',' });
                    if (arr.Length < 2)
                    {
                        continue;
                    }
                    int a = Convert.ToInt32(arr[0]);
                    int b = Convert.ToInt32(arr[1]);
                    if (s.IndexOf('a') != -1)
                    {
                        DelMeth      meth = new DelMeth(obj.AddNumbers);
                        IAsyncResult ar   = meth.BeginInvoke(a, b, null, null);
                        res = meth.EndInvoke(ar);
                    }
                    else
                    {
                        res = obj.AddNumbers(a, b);
                    }
                    Console.WriteLine("Got result: {0}", res);
                }
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.ReadLine();
            }
        }
示例#11
0
        static void Main(string[] args)
        {
            TcpClientChannel chanel = new TcpClientChannel();

            ChannelServices.RegisterChannel(chanel, false);
            RemotingConfiguration.RegisterWellKnownClientType(
                typeof(Class1), "tcp://localhost:1235/calculadora");
            try
            {
                while (true)
                {
                    Class1 op = new Class1();
                    Console.WriteLine(op.Suma(4, 3));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
            }
        }
示例#12
0
        public static void LaunchInExistingInstance(string[] args)
        {
            IpcChannel channel = new IpcChannel();

            ChannelServices.RegisterChannel(channel, false);
            string url = String.Format("ipc://{0}/{1}", ChannelName, SingleInstanceServiceName);

            // Register as client for remote object.
            WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(typeof(SingleInstanceHelper), url);

            RemotingConfiguration.RegisterWellKnownClientType(remoteType);

            // Create a message sink.
            string       objectUri;
            IMessageSink messageSink = channel.CreateMessageSink(url, null, out objectUri);


            SingleInstanceHelper helper = new SingleInstanceHelper();

            helper.Run(args);
        }
示例#13
0
        static void Main(string[] args)
        {
            /*  BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
             * provider.TypeFilterLevel = TypeFilterLevel.Full;
             * IDictionary props = new Hashtable();
             * props["port"] = 8086;
             * TcpChannel channel = new TcpChannel(props, null, provider);
             */
            //QuéIsto?
            TcpChannel channel = new TcpChannel(8086);

            ChannelServices.RegisterChannel(channel, true);

            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(AgentStorage),
                "AgentStorage",
                WellKnownObjectMode.Singleton);

            System.Console.WriteLine("<enter> para sair...");
            System.Console.ReadLine();
        }
示例#14
0
        protected override void OnStart(string[] args)
        {
            try
            {
                _httpChannel = new HttpChannel(9997);
                ChannelServices.RegisterChannel(_httpChannel, false);
            }
            catch (Exception ex)
            {
                _eventLog.WriteEntry("WatchDogService exception" + ex, EventLogEntryType.Error);
            }

            try
            {
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(WatchDogServer), "WatchDogServer", WellKnownObjectMode.SingleCall);
            }
            catch (Exception ex)
            {
                _eventLog.WriteEntry("WatchDogService exception" + ex, EventLogEntryType.Error);
            }
        }
示例#15
0
        public Form1()
        {
            InitializeComponent();
            HttpChannel chnl = new HttpChannel(1234);

            ChannelServices.RegisterChannel(chnl, false);

            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(ServerPartFactory),
                "_Server_",
                WellKnownObjectMode.Singleton);

            switch (ServerRand.Next(3))
            {
            case 0: ServerColor = this.BackColor = Color.Red; return;

            case 1: ServerColor = this.BackColor = Color.Green; return;

            case 2: ServerColor = this.BackColor = Color.Blue; return;
            }
        }
示例#16
0
        /// <summary>
        /// Initialize remoting server
        /// </summary>
        /// <param name="port"></param>
        /// <returns></returns>
        public static bool Startup(int port)
        {
            try
            {
//				Hashtable htParams  = new Hashtable();
//				htParams["port"]=port;
//				htParams["name"]="hndb";
                TcpServerChannel channel = new TcpServerChannel(port);

                ChannelServices.RegisterChannel(channel);
                RemotingConfiguration.RegisterWellKnownServiceType(
                    typeof(HNDBSVR),
                    "HNDBSVR",
                    WellKnownObjectMode.SingleCall);
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// 获取指定客户端名称的远程对象实例
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="clientName"></param>
        /// <returns></returns>
        public T GetWellKnownObject <T>(string clientName)
        {
            ClientConfig ci      = RemotingConfig.Instance.ClientInfoCollection[clientName];
            string       hostUrl = HostManager.Instance.GetCurrentHostAddress(clientName);

            if (string.IsNullOrEmpty(hostUrl))
            {
                hostUrl = RemotingConfig.Instance.ClientInfoCollection[clientName].DefaultHost.Url;
            }

            foreach (WellKnownClientTypeEntry entry in RemotingConfiguration.GetRegisteredWellKnownClientTypes())
            {
                if (entry.TypeName == typeof(T).FullName)
                {
                    return(GetWellKnownObject <T>(hostUrl, entry.ObjectUrl));
                }
            }

            //若没有在配置中映射类型的远程对象地址,那么用类型的全名称代替
            return(GetWellKnownObject <T>(hostUrl, typeof(T).FullName));
        }
示例#18
0
        public static void Main(string[] args)
        {
            TcpServerChannel tcpChannel = new TcpServerChannel(8086);

            ShowChannelProperties(tcpChannel);

            HttpServerChannel httpChannel = new HttpServerChannel(8085);

            ShowChannelProperties(httpChannel);

            ChannelServices.RegisterChannel(tcpChannel);
            ChannelServices.RegisterChannel(httpChannel);

            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(Wrox.ProfessionalCSharp.Hello),                  // Type
                "Hi",                                                   // URI
                WellKnownObjectMode.SingleCall);                        // Mode

            System.Console.WriteLine("hit to exit");
            System.Console.ReadLine();
        }
        static void Main(string[] args)
        {
            String filename = "eventlistener.exe.config";

            RemotingConfiguration.Configure(filename);

            IBroadcaster bcaster =
                (IBroadcaster)RemotingHelper.GetObject(typeof(IBroadcaster));

            Console.WriteLine("Registering event at server");

            // callbacks can only work on MarshalByRefObjects, so
            // I created a different class for this as well
            EventHandler eh = new EventHandler();

            bcaster.MessageArrived +=
                new MessageArrivedHandler(eh.HandleMessage);

            Console.WriteLine("Event registered. Waiting for messages.");
            Console.ReadLine();
        }
示例#20
0
        public Form1()
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(formClosing);

            PuppetMasterLog.form = this;

            channel = new TcpChannel(LOGGING_PORT);

            try {
                ChannelServices.RegisterChannel(channel, false);
                RemotingConfiguration.RegisterWellKnownServiceType(
                    typeof(PuppetMasterLog), "log",
                    WellKnownObjectMode.Singleton);
            } catch (RemotingException) { }

            importConfigFile(DEFAULT_CONFIG_PATH);

            consumer = new Thread(() => runCommands());
            consumer.Start();
        }
示例#21
0
        public ServerForm()
        {
            InitializeComponent();
            String hostName = Dns.GetHostName();
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();

            serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            IDictionary props = new Hashtable();

            props["port"]            = Port;
            props["typeFilterLevel"] = TypeFilterLevel.Full;

            HttpChannel chan = new HttpChannel(props, clientProvider, serverProvider);

            ChannelServices.RegisterChannel(chan, false);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject), "RemoteObject.soap", WellKnownObjectMode.SingleCall);

            AddTextToDisplay("Đang mở Port  " + Port + "..." + hostName);
            OnlineUserList = new Hashtable();
        }
示例#22
0
        public static void Main()
        {
            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();

            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();

            IDictionary props = new Hashtable();

            props["port"] = 9000;
            HttpChannel channel = new HttpChannel(props, clientProv, serverProv);

            ChannelServices.RegisterChannel(channel);
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(TimerService),
                "MyService/TimerService.soap",
                WellKnownObjectMode.Singleton);

            Console.WriteLine("Press enter to end the server process.");
            Console.ReadLine();
        }
示例#23
0
        public static void ShowWellKnownServiceTypes()
        {
            WellKnownServiceTypeEntry[] entries = RemotingConfiguration.GetRegisteredWellKnownServiceTypes();

            foreach (WellKnownServiceTypeEntry entry in entries)
            {
                Console.WriteLine("Assembly: " + entry.AssemblyName);
                Console.WriteLine("Mode: " + entry.Mode);
                Console.WriteLine("URI: " + entry.ObjectUri);
                Console.WriteLine("Type: " + entry.TypeName);

                IContextAttribute[] attributes = entry.ContextAttributes;
                if (attributes != null)
                {
                    foreach (ContextAttribute attribute in attributes)
                    {
                        Console.WriteLine("Context attribute: " + attribute.Name);
                    }
                }
            }
        }
示例#24
0
        static void Main(string[] args)
        {
            try
            {
                // setup .NET remoting
                System.Configuration.ConfigurationSettings.GetConfig("DNS");
                GenuineGlobalEventProvider.GenuineChannelsGlobalEvent += new GenuineChannelsGlobalEventHandler(GenuineChannelsEventHandler);
                //GlobalLoggerContainer.Logger = new BinaryLog(@"c:\tmp\server.log", false);
                RemotingConfiguration.Configure("Server.exe.config");

                // bind the server
                RemotingServices.Marshal(new ChatServer(), "ChatServer.rem");

                Console.WriteLine("Server has been started. Press enter to exit.");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}. Stack trace: {1}.", ex.Message, ex.StackTrace);
            }
        }
示例#25
0
        public static bool Init()
        {
            System.Console.Write("Type in a port to use for EndTransaction object: ");
            _port       = System.Console.ReadLine();
            _master_url = "tcp://localhost:8086/";
            _client_url = "tcp://localhost:" + _port + "/";

            // open a tcp channel to register the TransactionValues object
            // the port definition strategy needs to be taken into account
            channel = new TcpChannel(Convert.ToInt32(PadiDstm.Port));
            ChannelServices.RegisterChannel(channel, true);

            // register the EndTransaction object
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(EndTransaction),
                "EndTransaction",
                WellKnownObjectMode.SingleCall);

            _servers = new ServersCache();
            return(true);
        }
示例#26
0
        static void Main(string[] args)
        {
            RemotingConfiguration.Configure(@"../../App.config", true);

            int port = 8087;

            TcpChannel channel = new TcpChannel(port);

            ChannelServices.RegisterChannel(channel, false);

            RemotingConfiguration.RegisterWellKnownServiceType(typeof(MasterServer), "Server", WellKnownObjectMode.Singleton);
            System.Console.WriteLine("Registered Master");
            string host;

            host = getIP();

            System.IO.File.WriteAllText(@"../../../mServerLocation.dat", "tcp://" + host + ":" + port + "/Server");

            System.Console.WriteLine("SERVER ON");
            System.Console.ReadLine();
        }
示例#27
0
 public static void Main()
 {
     try
     {
         IClientChannelSinkProvider myFormatterProvider =
             new MyClientFormatterProvider();
         myFormatterProvider.Next =
             new SoapClientFormatterSinkProvider();
         TcpChannel myTcpChannel = new TcpChannel(null,
                                                  myFormatterProvider, null);
         ChannelServices.RegisterChannel(myTcpChannel, false);
         RemotingConfiguration.RegisterWellKnownClientType(typeof(HelloService),
                                                           "tcp://localhost:8082/HelloServiceApplication/MyUri");
         HelloService myService = new HelloService();
         Console.WriteLine(myService.HelloMethod("Welcome to .Net"));
     }
     catch (Exception ex)
     {
         Console.WriteLine("The following exception is raised at client side" + ex.Message);
     }
 }
示例#28
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Baumax.Localization.DefaultDiction.BuildDefaultResource();
            RemotingConfiguration.Configure("Baumax.Import.Test.exe.config");
            // Define channel security
            IEnumerator channelEnum = ChannelServices.RegisteredChannels.GetEnumerator();

            while (channelEnum.MoveNext())
            {
                BasicChannelWithSecurity channel = channelEnum.Current as BasicChannelWithSecurity;
                if (channel != null)
                {
                    channel.ITransportContext.IKeyStore.SetKey("/BAUMAX/SES",
                                                               new KeyProvider_SelfEstablishingSymmetric());
                }
            }
            SecuritySessionServices.SetCurrentSecurityContext(SecuritySessionServices.DefaultContext);
            Application.Run(new FrmMain());
        }
示例#29
0
        protected override void OnStart(string[] args)
        {
            string env_value = "";
            string env_key   = "jp.co.fit.vfreport.home";

            env_value = System.Environment.GetEnvironmentVariable(env_key);
            if (env_value == null || env_value.Equals(""))
            {
                env_value = ConfigurationSettings.AppSettings[env_key];
                System.Environment.SetEnvironmentVariable(env_key, env_value);
            }
            log.LogInfo("オークション帳票印刷サービスが開始しました。");

            //配置ファイルを読み込む。。

            RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);
            //リモートオブジェクトを取得する。

            //Utility.DumpAllInfoAboutRegisteredRemotingTypes();
            DumpTypeEntries(RemotingConfiguration.GetRegisteredWellKnownServiceTypes());
        }
示例#30
0
    public static void Main(string[] args)
    {
        string serverConfigFile = "basicserver.exe.config";

        if ((args.Length > 1) && (args[0].ToLower() == "/c" | args[0].ToLower() == "-c"))
        {
            serverConfigFile = args[1];
        }
        RemotingConfiguration.Configure("channels.config");
        RemotingConfiguration.Configure(serverConfigFile);

        Console.WriteLine("Listening...");

        string keyState = "";

        while (String.Compare(keyState, "0", true) != 0)
        {
            Console.WriteLine("***** Press 0 to exit this service *****");
            keyState = Console.ReadLine();
        }
    }