示例#1
0
        public MainWindow()
        {
            InitializeComponent();

            HttpChannel channel = new HttpChannel();
            ChannelServices.RegisterChannel(channel, false);

            // Registers the remote class. (This could be done with a
            // configuration file instead of a direct call.)
            RemotingConfiguration.RegisterWellKnownClientType(
                Type.GetType("Remote.ServiceClass, remote"),
                "http://localhost:8080/object1uri");

            // Instead of creating a new object, this obtains a reference
            // to the server's single instance of the ServiceClass object.
            ServiceClass object1 = new ServiceClass();

            try
            {
                MessageBox.Show("Suma " + object1.sum(1,3));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception of type: " + ex.ToString() + " occurred.");
                MessageBox.Show("Details: " + ex.Message);
            }
        }