public override void Open() { TcpChannel channel = new TcpChannel(Port); System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel( channel, false); System.Runtime.Remoting.RemotingConfiguration. RegisterWellKnownServiceType( typeof(FARemoteObject), "RemoteObject.rem", System.Runtime.Remoting.WellKnownObjectMode.Singleton); string url = string.Format("tcp://localhost:{0}/RemoteObject.rem", Port); _service = (FARemoteObject)Activator.GetObject(typeof(FARemoteObject), url); try { _service.ConnectTest(); // 최초 접속을 시도한다. } catch { // 접속에 실패해도 넘어간다. 이후 SetData(), GetData() 가 호출될 때 접속이 되는지 확인한다. } }
public override void Open() { IpcChannel channel = new IpcChannel(); System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false); string host = string.Format("ipc://localhost:{0}", Port); System.Runtime.Remoting.WellKnownClientTypeEntry remoteType = new System.Runtime.Remoting.WellKnownClientTypeEntry( typeof(FARemoteObject), host + "/RemoteObject.rem"); System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownClientType(remoteType); string objectUri; System.Runtime.Remoting.Messaging.IMessageSink messageSink = channel.CreateMessageSink( host + "/RemoteObject.rem", null, out objectUri); if (messageSink == null) { throw new Exception(string.Format("{0} Open fail. fail create message sink", Name)); } _service = new FARemoteObject(); try { _service.ConnectTest(); // 최초 접속을 시도한다. } catch { // 접속에 실패해도 넘어간다. 이후 SetData(), GetData() 가 호출될 때 접속이 되는지 확인한다. } }