Remoting创建远程对象的一个实例:

        private static Lazy<IChannelManager>  channelManager=new Lazy<IChannelManager>(() =>
        {
            if (ChannelManagerUrl == null)
                throw new InvalidOperationException("未设置ChannelManagerUrl");

            Trace.TraceInformation("ChannelManagerUrl={0}", ChannelManagerUrl);
            IChannelManager m = null;
            if (ChannelManagerUrl.StartsWith("tcp://") || ChannelManagerUrl.StartsWith("http://") || ChannelManagerUrl.StartsWith("ipc://"))
            {
                m = (IChannelManager)Activator.GetObject(typeof(IChannelManager), ChannelManagerUrl);
            }
            return m;
        });

posted on 2016-09-29 11:44  跨界农民工  阅读(371)  评论(0编辑  收藏  举报

导航