日期:2014-05-19  浏览次数:20824 次

关于 Remoting
using   System;
using   System.Collections;
using   System.Runtime.Remoting;
using   System.Runtime.Remoting.Channels;
using   System.Runtime.Remoting.Channels.Tcp;
using   System.Security.Permissions;
using   System.Runtime.Serialization.Formatters;
using   Remote;

namespace   YiLongServer
{
        [Serializable]
        class   Server
        {
                static   void   Main(string[]   args)
                {
                        BinaryServerFormatterSinkProvider   provider   =   new   BinaryServerFormatterSinkProvider();
                        provider.TypeFilterLevel   =   TypeFilterLevel.Full;
                        IDictionary   props   =   new   Hashtable();
                        props[ "port "]   =   9090;
                        TcpChannel   serverChannel   =   new   TcpChannel(props,   null,   provider);
                        ChannelServices.RegisterChannel(serverChannel,   false);
                        RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject),   "Update ",   WellKnownObjectMode.SingleCall);
                        Console.WriteLine( "Press   return   to   exit ");
                        Console.ReadLine();
                }
        }
}

服务器


远程对象

using   System;
using   System.Data;
using   System.Threading;
using   System.Data.SqlClient;

namespace   Remote
{
        public   class   RemoteObject   :   MarshalByRefObject
        {
                public   delegate   void   StatusEvent(object   sender,   StatusEventArgs   e);

                public   event   StatusEvent   Status;

                public   RemoteObject()
                {
                        Console.WriteLine( "One   Object   has   created ");
                }

                ~RemoteObject()
                {
                        Console.WriteLine( "One   Object   has