コード例 #1
0
ファイル: Program.cs プロジェクト: cdanielgomes/FEUP-TDIN
        public static void Main(string[] args)
        {
            IDictionary props = new Hashtable();

            props["port"] = 0; // let the system choose a free port
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();

            serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
            TcpChannel chan = new TcpChannel(props, clientProvider, serverProvider); // instantiate the channel

            ChannelServices.RegisterChannel(chan, false);                            // register the channel

            ChannelDataStore data = (ChannelDataStore)chan.ChannelData;
            int port = new Uri(data.ChannelUris[0]).Port; // get the port


            RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteClient), "RemoteClient",
                                                               WellKnownObjectMode.Singleton); // register my remote object for service

            ClientApp.Init("tcp://localhost:" + port + "/RemoteClient");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LoginWindow());
        }