public override void Open()
{
TcpChannel channel = new TcpChannel();
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
string host = string.Format("tcp://{0}:{1}", Address, 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() 가 호출될 때 접속이 되는지 확인한다.
}
}