public WellKnownServiceTypeEntry(Type !type, string !objectUri, WellKnownObjectMode mode)
        {
            CodeContract.Requires(type != null);
            CodeContract.Requires(objectUri != null);

            return(default(WellKnownServiceTypeEntry));
        }
Example #2
0
 internal RedirectionProxy(MarshalByRefObject proxy, Type serverType)
 {
     this._proxy      = proxy;
     this._realProxy  = RemotingServices.GetRealProxy(this._proxy);
     this._serverType = serverType;
     this._objectMode = WellKnownObjectMode.Singleton;
 }
 internal ServerWellKnownEntry AddServerWellKnownEntry(string typeName, string assemName, ArrayList contextAttributes, string objURI, WellKnownObjectMode objMode)
 {
     this.TryToLoadTypeIfApplicable(typeName, assemName);
     ServerWellKnownEntry entry = new ServerWellKnownEntry(typeName, assemName, contextAttributes, objURI, objMode);
     this.ServerWellKnownEntries.Add(entry);
     return entry;
 }
Example #4
0
        private TcpServerChannel TcpCreateServer <T>(string name, string address, WellKnownObjectMode mode, T obj) where T : MarshalByRefObject
        {
            TcpServerChannel channel = ChannelServices.GetChannel(name) as TcpServerChannel;

            if (channel == null)
            {
                BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
                serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
                //Instantiate our server channel.
                channel = new TcpServerChannel(name, (int)_port, serverProvider);
                //Register the server channel.
                ChannelServices.RegisterChannel(channel, false);
            }

            var c = channel.GetChannelUri();

            //Register this service type.
            if (obj == null)
            {
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(T), address, mode);
            }
            else
            {
                RemotingServices.Marshal(obj, address);
            }
            return(channel);
        }
Example #5
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                btnStop.PerformClick();
                port = Convert.ToInt32(txtPort.Text);
                //Tạo channel truyền dữ liệu
                tcpChannel = new TcpChannel(port);
                ChannelServices.RegisterChannel(tcpChannel, false);
                //Đăng ký remote object với Remoting framework
                type   = typeof(PrimeProxy);
                objURI = "PRIME_URI";
                if (radSingleton.Checked)
                {
                    wellKnownMode = WellKnownObjectMode.Singleton;
                }
                else
                {
                    wellKnownMode = WellKnownObjectMode.SingleCall;
                }
                RemotingConfiguration.RegisterWellKnownServiceType(type, objURI, wellKnownMode);

                txtStatus.Text = "Start in Port: " + port.ToString() + " at: " + DateTime.Now.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi");
            }
        }
Example #6
0
 /// <summary>
 ///     Creates a globally reachable, managed IPC-Port.
 /// </summary>
 /// <remarks>
 ///     Because it is something tricky to get a port working for any constellation of
 ///     target processes, I decided to write a proper wrapper method. Just keep the returned
 ///     <see cref="IpcChannel" /> alive, by adding it to a global list or static variable,
 ///     as long as you want to have the IPC port open.
 /// </remarks>
 /// <typeparam name="TRemoteObject">
 ///     A class derived from <see cref="MarshalByRefObject" /> which provides the
 ///     method implementations this server should expose.
 /// </typeparam>
 /// <param name="InObjectMode">
 ///     <see cref="WellKnownObjectMode.SingleCall" /> if you want to handle each call in an new
 ///     object instance, <see cref="WellKnownObjectMode.Singleton" /> otherwise. The latter will implicitly
 ///     allow you to use "static" remote variables.
 /// </param>
 /// <param name="RefChannelName">
 ///     Either <c>null</c> to let the method generate a random channel name to be passed to
 ///     <see cref="IpcConnectClient{TRemoteObject}" /> or a predefined one. If you pass a value unequal to
 ///     <c>null</c>, you shall also specify all SIDs that are allowed to connect to your channel!
 /// </param>
 /// <param name="InAllowedClientSIDs">
 ///     If no SID is specified, all authenticated users will be allowed to access the server
 ///     channel by default. You must specify an SID if <paramref name="RefChannelName" /> is unequal to <c>null</c>.
 /// </param>
 /// <returns>
 ///     An <see cref="IpcChannel" /> that shall be keept alive until the server is not needed anymore.
 /// </returns>
 /// <exception cref="System.Security.HostProtectionException">
 ///     If a predefined channel name is being used, you are required to specify a list of well known SIDs
 ///     which are allowed to access the newly created server.
 /// </exception>
 /// <exception cref="RemotingException">
 ///     The given channel name is already in use.
 /// </exception>
 public static IpcServerChannel IpcCreateServer <TRemoteObject>(
     ref String RefChannelName,
     WellKnownObjectMode InObjectMode,
     params WellKnownSidType[] InAllowedClientSIDs) where TRemoteObject : MarshalByRefObject
 {
     return(IpcCreateServer <TRemoteObject>(ref RefChannelName, InObjectMode, null, InAllowedClientSIDs));
 }
Example #7
0
 internal RedirectionProxy(MarshalByRefObject proxy, Type serverType)
 {
     _proxy = proxy;
     _realProxy = RemotingServices.GetRealProxy(_proxy);
     _serverType = serverType;
     _objectMode = WellKnownObjectMode.Singleton;
 } // RedirectionProxy
 public WellKnownServiceTypeEntry(Type type, string objectUri, WellKnownObjectMode mode)
 {
     AssemblyName = type.Assembly.FullName;
     TypeName     = type.FullName;
     obj_type     = type;
     obj_uri      = objectUri;
     obj_mode     = mode;
 }
		public WellKnownServiceTypeEntry (Type type, string objectUri, WellKnownObjectMode mode)			
		{
			AssemblyName = type.Assembly.FullName;
			TypeName = type.FullName;
			obj_type = type;
			obj_uri = objectUri;
			obj_mode = mode;
		}
        public static void RegisterWellKnownServiceType(
            Type type, String objectUri, WellKnownObjectMode mode)
        {
            WellKnownServiceTypeEntry wke =
                new WellKnownServiceTypeEntry(type, objectUri, mode);

            RemotingConfiguration.RegisterWellKnownServiceType(wke);
        } // RegisterWellKnownServiceType
 public static void StartRemoting <T>
 (
     string Url
     , int Port
     , WellKnownObjectMode Mode
 )
 {
     StartRemoting(typeof(T), Url, Port, Mode);
 }
Example #12
0
        public static TInterface CreateProxy <T, TInterface, TSerializer>(
            this AppDomain domain,
            WellKnownObjectMode mode,
            TSerializer serializer)
#endif
            where T : TInterface, new()
            where TSerializer : ITextSerialization, new()
        {
            return(CreateProxy <T, TInterface, TSerializer>(domain, new T(), mode, serializer));
        }
Example #13
0
        public bool CreateChannel(string specName, bool useSingleton = false)
        {
            string FullName  = this.GetType().Name;
            string ClassName = FullName.Split('\'')[0];
            //if (specName != null)
            //{
            //    ClassName = specName;
            //}
            string ChannelName = string.Format("IPC_{0}", specName);
            string cname       = string.Format("{0}_{1}", specName, ClassName);

            //if (ClassName != null)
            //    ChannelName = ClassName;
            try
            {
                ToLog("IPC服务端日志", "检查是否是管理员", WinComminuteClass.IsRoot().ToString());
                ToLog("IPC服务端日志", "正在初始化通道", ChannelName);
                if (!channels.ContainsKey(ChannelName))
                {
                    ToLog("IPC服务端日志", "注册通道", ChannelName);
                    Hashtable ht = new Hashtable();
                    ht["portName"]        = ChannelName;
                    ht["name"]            = "ipc";
                    ht["authorizedGroup"] = "everyone";

                    BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
                    serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
                    BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
                    //IDictionary props = new Hashtable();
                    //props["port"] = Convert.ToInt32(txtClientPort.Text);
                    //HttpChannel chan = new HttpChannel(props, clientProv, serverProv);
                    //CommonSecurityDescriptor csd = new CommonSecurityDescriptor();
                    IpcServerChannel channel = new IpcServerChannel(ht, serverProv);
                    //IpcServerChannel channel = new IpcServerChannel(ChannelName);
                    ChannelServices.RegisterChannel(channel, false);
                    //ToLog("IPC服务端日志", "正在注册通道绑定数据类型", ClassName);
                    ToLog("IPC服务端日志", "注册通道完毕", channel.ChannelName);
                    channels.Add(ChannelName, channel);
                    WellKnownObjectMode mode = useSingleton ? WellKnownObjectMode.Singleton : WellKnownObjectMode.SingleCall;
                    RemotingConfiguration.RegisterWellKnownServiceType(this.GetType(), ClassName, mode);
                    ToLog("IPC服务端日志", "绑定数据类型完毕", ClassName);
                }

                ToLog("IPC服务端日志", string.Format("初始化通道成功"), WinComminuteClass.getAllChannelsInfo());
                //IpcServerChannel channel = new IpcServerChannel(string.Format("WolfIPC_Channel"));
                //RemoteCommClass<T> obj = new RemoteCommClass<T>();
            }
            catch (Exception e)
            {
                ToLog("IPC服务端日志", string.Format("初始化通道[{0},{1}]失败", specName, FullName), e.Message);
                return(false);
            }
            return(true);
        }
        //解析WellKnown对象
        void ParseWellKnownServerObjectSection(XmlNode root)
        {
            foreach (XmlNode node in root.ChildNodes)
            {
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }
                if (node.Name != "add")
                {
                    continue;
                }

                string objectUri = base.GetStringAttribute(node, "objectUri");
                if (string.IsNullOrEmpty(objectUri))
                {
                    continue;
                }

                string fullTypeName = base.GetStringAttribute(node, "type");
                if (string.IsNullOrEmpty(fullTypeName))
                {
                    continue;
                }

                string mode = base.GetStringAttribute(node, "mode").ToLower();


                string typeName     = fullTypeName.Split(',')[0];
                string assemblyName = string.Empty;

                if (fullTypeName.IndexOf(',') != -1)
                {
                    assemblyName = fullTypeName.Split(',')[1];
                }
                else
                {
                    Assembly assembly = ReflectUtil.FindAssemblyFromAppDirectory(typeName);
                    if (assembly != null)
                    {
                        assemblyName = assembly.FullName;
                    }
                }

                WellKnownObjectMode objectMode = WellKnownObjectMode.Singleton;
                if (mode == "singlecall")
                {
                    objectMode = WellKnownObjectMode.SingleCall;
                }

                WellKnownServiceTypeEntry wse = new WellKnownServiceTypeEntry(typeName, assemblyName, objectUri, objectMode);
                si.AddWellKnownObject(wse);
            }
        }
		public WellKnownServiceTypeEntry (string typeName, string assemblyName,
						  string objectUri, WellKnownObjectMode mode)			
		{
			AssemblyName = assemblyName;
			TypeName = typeName;
			Assembly a = Assembly.Load (assemblyName);
			obj_type = a.GetType (typeName);
			obj_uri = objectUri;
			obj_mode = mode;
			if (obj_type == null) 
				throw new RemotingException ("Type not found: " + typeName + ", " + assemblyName);
		}
        internal static void RegisterWellKnownServiceType(WellKnownServiceTypeEntry entry)
        {
            string typeName          = entry.TypeName;
            string assemblyName      = entry.AssemblyName;
            string objectUri         = entry.ObjectUri;
            WellKnownObjectMode mode = entry.Mode;

            lock (Info)
            {
                Info.AddWellKnownEntry(entry);
            }
        }
Example #17
0
        /// <summary>
        /// 注册远程对象。
        /// </summary>
        /// <param name="type">远程对象类型。</param>
        /// <param name="url">远程对象的Url。</param>
        /// <param name="model">远程对象的注册模式。SingleCall 或者 Singleton</param>
        /// <returns>true:注册成功。false:注册失败。</returns>
        public static bool RegisterRemoteObject(string type, string url, string model)
        {
            try
            {
                WellKnownObjectMode objMod = (WellKnownObjectMode)Enum.Parse(typeof(WellKnownObjectMode), model);
                RemotingConfiguration.RegisterWellKnownServiceType(Type.GetType(type), url, objMod);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(true);
        }
Example #18
0
        /// <summary>
        /// Runs this program as a server.
        /// </summary>
        public static void Run(ChannelKind ChanKind, WellKnownObjectMode ObjMode, Type ObjType)
        {
            TcpChannel  tcpchan;
            HttpChannel httpchan;

            System.Collections.Hashtable httpproperties;
            System.Collections.Hashtable tcpproperties;

            Console.WriteLine("\nStarting server in WellKnownObjectMode {0}\n", ObjMode.ToString());

            switch (ChanKind)
            {
            case ChannelKind.Http:
                httpproperties         = new System.Collections.Hashtable();
                httpproperties["port"] = Server.HTTPPORT;
                httpchan = new HttpChannel(httpproperties, null, GetProviderChain());
                ChannelServices.RegisterChannel(httpchan);
                break;

            case ChannelKind.TCP:
                tcpproperties         = new System.Collections.Hashtable();
                tcpproperties["port"] = Server.TCPPORT;
                tcpchan = new TcpChannel(tcpproperties, null, GetProviderChain());
                ChannelServices.RegisterChannel(tcpchan);
                break;

            case ChannelKind.Both:
                httpproperties         = new System.Collections.Hashtable();
                httpproperties["port"] = Server.HTTPPORT;
                httpchan = new HttpChannel(httpproperties, null, GetProviderChain());
                ChannelServices.RegisterChannel(httpchan);

                tcpproperties         = new System.Collections.Hashtable();
                tcpproperties["port"] = Server.TCPPORT;
                tcpchan = new TcpChannel(tcpproperties, null, GetProviderChain());
                ChannelServices.RegisterChannel(tcpchan);
                break;

            default:
                throw new System.InvalidOperationException("Unexpected Channel kind in Server.Run()");
            }//switch

            RemotingConfiguration.RegisterWellKnownServiceType(ObjType,
                                                               "SayHello",
                                                               ObjMode);

            System.Console.WriteLine("Hit <enter> to exit...");
            System.Console.ReadLine();
            return;
        }
Example #19
0
        /// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Remoting.WellKnownServiceTypeEntry" /> class with the given type name, assembly name, object URI, and <see cref="T:System.Runtime.Remoting.WellKnownObjectMode" />.</summary>
        /// <param name="typeName">The full type name of the server-activated service type. </param>
        /// <param name="assemblyName">The assembly name of the server-activated service type. </param>
        /// <param name="objectUri">The URI of the server-activated object. </param>
        /// <param name="mode">The <see cref="T:System.Runtime.Remoting.WellKnownObjectMode" /> of the type, which defines how the object is activated. </param>
        public WellKnownServiceTypeEntry(string typeName, string assemblyName, string objectUri, WellKnownObjectMode mode)
        {
            base.AssemblyName = assemblyName;
            base.TypeName     = typeName;
            Assembly assembly = Assembly.Load(assemblyName);

            this.obj_type = assembly.GetType(typeName);
            this.obj_uri  = objectUri;
            this.obj_mode = mode;
            if (this.obj_type == null)
            {
                throw new RemotingException("Type not found: " + typeName + ", " + assemblyName);
            }
        }
Example #20
0
        public static TInterface CreateProxy <T, TInterface, TSerializer>(
            this AppDomain domain,
            T instance,
            WellKnownObjectMode mode,
            TSerializer serializer)
#endif
            where T : TInterface, new()
            where TSerializer : ITextSerialization, new()
        {
            return((TInterface) new CrossAppDomainProxy <T, TInterface, TSerializer>(
                       domain,
                       instance,
                       mode,
                       serializer).GetTransparentProxy());
        }
        /// <include file='doc\RemotingConfiguration.uex' path='docs/doc[@for="WellKnownServiceTypeEntry.WellKnownServiceTypeEntry1"]/*' />
        public WellKnownServiceTypeEntry(Type type, String objectUri, WellKnownObjectMode mode)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (objectUri == null)
            {
                throw new ArgumentNullException("objectUri");
            }

            TypeName     = type.FullName;
            AssemblyName = type.Module.Assembly.nGetSimpleName();
            _objectUri   = objectUri;
            _mode        = mode;
        }
	// Constructor.
	public WellKnownServiceTypeEntry(Type type, String objectUri,
									 WellKnownObjectMode mode)
			{
				if(type == null)
				{
					throw new ArgumentNullException("type");
				}
				if(objectUri == null)
				{
					throw new ArgumentNullException("objectUri");
				}
				actualType = type;
				TypeName = type.FullName;
				AssemblyName = type.Assembly.FullName;
				this.objectUri = objectUri;
				this.mode = mode;
			}
Example #23
0
 // Constructor.
 public WellKnownServiceTypeEntry(Type type, String objectUri,
                                  WellKnownObjectMode mode)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (objectUri == null)
     {
         throw new ArgumentNullException("objectUri");
     }
     actualType     = type;
     TypeName       = type.FullName;
     AssemblyName   = type.Assembly.FullName;
     this.objectUri = objectUri;
     this.mode      = mode;
 }
 public CrossAppDomainProxy(AppDomain domain, T instance, WellKnownObjectMode mode, TSerializer serializer)
     : base(typeof(ContextBoundObject))
 {
     this.domain     = domain;
     ProxyId         = Guid.NewGuid();
     this.instance   = instance;
     this.mode       = mode;
     this.serializer = serializer;
     if (mode == WellKnownObjectMode.Singleton)
     {
         AppDomainCallbackExtensions.DoCallBack(
             domain,
             ProxyId,
             (object)instance,
             CrossAppDomainProxyHelper.RegisterSingletonInstance,
             serializer);
     }
 }
Example #25
0
        /// <summary>
        /// 启动
        /// </summary>
        public virtual void Start(WellKnownObjectMode mode)
        {
            var serverProvider = new BinaryServerFormatterSinkProvider();
            var clientProvider = new BinaryClientFormatterSinkProvider();

            serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary props = new Hashtable
            {
                ["portName"] = string.Format("ServerChannel-Server.{0}", typeof(T).Name)
            };

            serverChannel = new IpcChannel(props, clientProvider, serverProvider);
            // 注册这个IPC信道.
            ChannelServices.RegisterChannel(serverChannel, true);
            // 向信道暴露一个远程对象.
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(T), "IPCObject", mode);
            IBusy = true;
        }
Example #26
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Runtime.Remoting.WellKnownServiceTypeEntry" /> class with the given <see cref="T:System.Type" />, object URI, and <see cref="T:System.Runtime.Remoting.WellKnownObjectMode" />.</summary>
 /// <param name="type">The <see cref="T:System.Type" /> of the server-activated service type object. </param>
 /// <param name="objectUri">The URI of the server-activated type. </param>
 /// <param name="mode">The <see cref="T:System.Runtime.Remoting.WellKnownObjectMode" /> of the type, which defines how the object is activated. </param>
 // Token: 0x060054EB RID: 21739 RVA: 0x0012C904 File Offset: 0x0012AB04
 public WellKnownServiceTypeEntry(Type type, string objectUri, WellKnownObjectMode mode)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (objectUri == null)
     {
         throw new ArgumentNullException("objectUri");
     }
     if (!(type is RuntimeType))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
     }
     base.TypeName     = type.FullName;
     base.AssemblyName = type.Module.Assembly.FullName;
     this._objectUri   = objectUri;
     this._mode        = mode;
 }
 public WellKnownServiceTypeEntry(string typeName, string assemblyName, string objectUri, WellKnownObjectMode mode)
 {
     if (typeName == null)
     {
         throw new ArgumentNullException("typeName");
     }
     if (assemblyName == null)
     {
         throw new ArgumentNullException("assemblyName");
     }
     if (objectUri == null)
     {
         throw new ArgumentNullException("objectUri");
     }
     base.TypeName     = typeName;
     base.AssemblyName = assemblyName;
     this._objectUri   = objectUri;
     this._mode        = mode;
 }
 public WellKnownServiceTypeEntry(Type type, string objectUri, WellKnownObjectMode mode)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (objectUri == null)
     {
         throw new ArgumentNullException("objectUri");
     }
     if (!(type is RuntimeType))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));
     }
     base.TypeName = type.FullName;
     base.AssemblyName = type.Module.Assembly.FullName;
     this._objectUri = objectUri;
     this._mode = mode;
 }
 public WellKnownServiceTypeEntry(string typeName, string assemblyName, string objectUri, WellKnownObjectMode mode)
 {
     if (typeName == null)
     {
         throw new ArgumentNullException("typeName");
     }
     if (assemblyName == null)
     {
         throw new ArgumentNullException("assemblyName");
     }
     if (objectUri == null)
     {
         throw new ArgumentNullException("objectUri");
     }
     base.TypeName = typeName;
     base.AssemblyName = assemblyName;
     this._objectUri = objectUri;
     this._mode = mode;
 }
        public static void StartRemoting
        (
            Type RemotingType
            , string Url
            , int Port
            , WellKnownObjectMode ServiceMode
        )
        {
            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();

            provider.TypeFilterLevel = TypeFilterLevel.Full;
            IDictionary ht = new Hashtable();

            ht["port"] = Port;
            TcpChannel tc = new TcpChannel(ht, null, provider);

            ChannelServices.RegisterChannel(tc, false);
            RemotingConfiguration.RegisterWellKnownServiceType(RemotingType, Url, ServiceMode);
            Console.WriteLine("Remoting Object Started ...");
        }
Example #31
0
 private void myServerStart()
 {
     try
     {
         myServerStop();
         //Tạo kênh
         tcpChannel = new TcpChannel(port);
         ChannelServices.RegisterChannel(tcpChannel, false);
         //Dang ky
         type          = typeof(PrimeProxy);
         objURI        = "PRIME_URI";
         wellKnownMode = WellKnownObjectMode.Singleton;
         RemotingConfiguration.RegisterWellKnownServiceType(type, objURI, wellKnownMode);
         eventLog1.WriteEntry("Server khởi động tại port " + port.ToString() + " lúc " + DateTime.Now.ToString());
     }
     catch (Exception ex)
     {
         eventLog1.WriteEntry("Lỗi: " + ex.Message);
     }
 }
Example #32
0
        //aPort 8068
        public override bool openConnection(int aPort)
        {
            try
            {
                BinaryServerFormatterSinkProvider serverFormatter =
                    new BinaryServerFormatterSinkProvider();

                serverFormatter.TypeFilterLevel = TypeFilterLevel.Full;

                BinaryClientFormatterSinkProvider clientProv =
                    new BinaryClientFormatterSinkProvider();

                Hashtable props = new Hashtable();
                props["port"] = aPort;
                props["name"] = RemotingObjectName;

                // now create and register our custom HttpChannel
                mpChannel = new TcpChannel(props, clientProv, serverFormatter);
                ChannelServices.RegisterChannel(mpChannel, false);
                WellKnownObjectMode       mode  = WellKnownObjectMode.Singleton;
                WellKnownServiceTypeEntry entry = new WellKnownServiceTypeEntry(
                    typeof(LibRemotingObj.ModelRemoteObject),
                    RemotingObjectName,
                    mode);
                ////
                //LifetimeServices.LeaseTime = TimeSpan.FromSeconds(10);
                //LifetimeServices.LeaseManagerPollTime = TimeSpan.FromSeconds(3);
                //LifetimeServices.RenewOnCallTime = TimeSpan.FromSeconds(2);
                //LifetimeServices.SponsorshipTimeout = TimeSpan.FromSeconds(1);
                ////
                RemotingConfiguration.RegisterWellKnownServiceType(entry);
                return(true);
            }
            catch (Exception)
            {
                ChannelServices.UnregisterChannel(mpChannel);
                mpChannel = null;
            }
            return(false);
        }
Example #33
0
        // Registers a new Remoting httpChannel utilizing SOAP formatter for serialization
        private void RegisterChannel()
        {
            Console.WriteLine("[Remoting Server]: Registering httpChannel");

            try
            {
                // Set the TypeFilterLevel to Full since callbacks require additional security requirements
                SoapServerFormatterSinkProvider serverFormatter = new SoapServerFormatterSinkProvider();
                serverFormatter.TypeFilterLevel = TypeFilterLevel.Full;

                // We have to change the name since we can't have two channels with the same name.
                Hashtable ht = new Hashtable();
                ht["name"] = "ServerChannel";
                ht["port"] = 9000;

                // Now create and register our custom HttpChannel
                HttpChannel channel = new HttpChannel(ht, null, serverFormatter);
                ChannelServices.RegisterChannel(channel, false);

                // Register a 'Well Known Object' type in Singleton mode
                string identifier        = "RUETalk";
                WellKnownObjectMode mode = WellKnownObjectMode.Singleton;

                // Register our Object model (RemotingComms)
                WellKnownServiceTypeEntry entry = new WellKnownServiceTypeEntry(typeof(RemotingComms), identifier, mode);
                RemotingConfiguration.RegisterWellKnownServiceType(entry);
            }
            catch (Exception e)
            {
                if (!e.Message.Contains("Prefix already in use."))
                {
                    Console.WriteLine("[Remoting Server ERROR]: Message - " + e.Message);
                }
                else
                {
                    Console.WriteLine("[Remoting Server]: httpChannel Registered");
                }
            }
        }
        public WellKnownServiceTypeEntry(String typeName, String assemblyName, String objectUri,
                                         WellKnownObjectMode mode)
        {
            if (typeName == null)
            {
                throw new ArgumentNullException("typeName");
            }
            if (assemblyName == null)
            {
                throw new ArgumentNullException("assemblyName");
            }
            if (objectUri == null)
            {
                throw new ArgumentNullException("objectUri");
            }
            Contract.EndContractBlock();

            TypeName     = typeName;
            AssemblyName = assemblyName;
            _objectUri   = objectUri;
            _mode        = mode;
        }
Example #35
0
        private void registerChannel()
        {
            // set typefilterlevel to higher security
            SoapServerFormatterSinkProvider serverFormatter = new SoapServerFormatterSinkProvider();

            serverFormatter.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            // setup dictionary with values
            Hashtable ht = new Hashtable();

            ht["name"] = "ServerChannel";
            ht["port"] = 9000;
            // create and register the channel
            HttpChannel channel = new HttpChannel(ht, null, serverFormatter);

            ChannelServices.RegisterChannel(channel, false);
            // register a wellknown type in singleton mode
            string identifier = "commBuffer";
            WellKnownObjectMode       mode  = WellKnownObjectMode.Singleton;
            WellKnownServiceTypeEntry entry = new WellKnownServiceTypeEntry(typeof(osgCommBuffer),
                                                                            identifier, mode);

            RemotingConfiguration.RegisterWellKnownServiceType(entry);
        }
Example #36
0
        public static void CreateAndRegisterChannel(Type type)
        {
            IChannel channel     = new TcpChannel(int.Parse(System.Configuration.ConfigurationManager.AppSettings["ChannelPort"]));
            string   channelType = System.Configuration.ConfigurationManager.AppSettings["ChannelType"];

            if (channelType.ToLower() == "http")
            {
                channel = new HttpChannel(int.Parse(System.Configuration.ConfigurationManager.AppSettings["ChannelPort"]));
            }
            else if (channelType.ToLower() == "ipc")
            {
                channel = new IpcChannel(System.Configuration.ConfigurationManager.AppSettings["IpcChannelPortName"]);
            }
            bool   ensureSecurity = false;
            string security       = System.Configuration.ConfigurationManager.AppSettings["EnsureSecurity"];

            if (security == "1")
            {
                ensureSecurity = true;
            }
            ChannelServices.RegisterChannel(channel, ensureSecurity);
            string registerMode      = System.Configuration.ConfigurationManager.AppSettings["WellKnownObjectMode"];
            WellKnownObjectMode wkom = WellKnownObjectMode.Singleton;

            if (registerMode.ToLower() == "singlecall")
            {
                wkom = WellKnownObjectMode.SingleCall;
            }
            string objectClass = System.Configuration.ConfigurationManager.AppSettings["ObjectClass"];
            string objectUri   = "RemoteObject";

            if (!string.IsNullOrEmpty(objectClass))
            {
                objectUri = objectClass;
            }
            RemotingConfiguration.RegisterWellKnownServiceType(type, objectUri, wkom);
        }
Example #37
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            txtPort.Enabled     = false;
            cmbProtocol.Enabled = false;
            btnStart.Enabled    = false;

            int port = int.Parse(txtPort.Text.Trim());

            if (cmbProtocol.SelectedIndex == 0) // tcp
            {
                ChannelServices.RegisterChannel(new TcpChannel(port), false);
            }
            else if (cmbProtocol.SelectedIndex == 1) // http
            {
                ChannelServices.RegisterChannel(new HttpChannel(port), false);
            }

            WellKnownObjectMode mode = WellKnownObjectMode.SingleCall;

            RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;

            RemotingConfiguration.RegisterWellKnownServiceType(typeof(FoodBLL), "FoodBLL", mode);
            lblStatus.Text = "STATUS: SERVER is starting with PORT = " + port;
        }
 public static void RegisterWellKnownServiceType(
     Type type, String objectUri, WellKnownObjectMode mode)
 {
     WellKnownServiceTypeEntry wke = 
         new WellKnownServiceTypeEntry(type, objectUri, mode);        
     RemotingConfiguration.RegisterWellKnownServiceType(wke); 
 } // RegisterWellKnownServiceType
 /// <summary>
 /// Publishes the well known service instance.
 /// </summary>
 /// <param name="notifyName">Name of the notify.</param>
 /// <param name="interfaceType">Type of the interface.</param>
 /// <param name="mode">The mode.</param>
 public void PublishWellKnownServiceInstance(string notifyName, Type interfaceType, WellKnownObjectMode mode)
 {
     PublishWellKnownServiceInstance(notifyName, interfaceType, null, mode);
 }
 public static void RegisterWellKnownServiceType(Type type, string objectUri, WellKnownObjectMode mode)
 {
 }
        /// <summary>
        /// Publishes the well known service instance.
        /// </summary>
        /// <param name="notifyName">Name of the notify.</param>
        /// <param name="interfaceType">Type of the interface.</param>
        /// <param name="instance">The instance.</param>
        /// <param name="mode">The mode.</param>
        public void PublishWellKnownServiceInstance(string notifyName, Type interfaceType, MarshalByRefObject instance, WellKnownObjectMode mode)
        {
            WriteLog("Instance URL --> " + BuildUrl(notifyName), LogType.Information);

            RemotingConfiguration.RegisterWellKnownServiceType(interfaceType, BuildUrl(notifyName), mode);
            ObjRef objRef = RemotingServices.Marshal(instance, notifyName);

            if (instance == null)
                WriteLog("(" + BuildUrl(notifyName) + ") start listening at port: " + serverPort, LogType.Information);
            else
                WriteLog("(" + instance.ToString() + ") start listening at port: " + serverPort, LogType.Information);
        }
Example #42
0
		internal static ServerIdentity CreateWellKnownServerIdentity(Type objectType, string objectUri, WellKnownObjectMode mode)
		{
			ServerIdentity identity;

			if (mode == WellKnownObjectMode.SingleCall)
				identity = new  SingleCallIdentity(objectUri, Context.DefaultContext, objectType);
			else
				identity = new  SingletonIdentity(objectUri, Context.DefaultContext, objectType);

			RegisterServerIdentity (identity);
			return identity;
		}
		public static void RegisterWellKnownServiceType (Type type, string objectUri, WellKnownObjectMode mode) 
		{
			RegisterWellKnownServiceType (new WellKnownServiceTypeEntry (type, objectUri, mode));
		}
 public WellKnownServiceTypeEntry (string! typeName, string! assemblyName, string! objectUri, WellKnownObjectMode mode) {
     CodeContract.Requires(typeName != null);
     CodeContract.Requires(assemblyName != null);
     CodeContract.Requires(objectUri != null);
   return default(WellKnownServiceTypeEntry);
 }
Example #45
0
 public RpcAttribute(bool ForServer, WellKnownObjectMode Mode, params int[] AllowedID)
 {
     this.ForServer = ForServer;
     this.Mode = Mode;
     this.AllowedID = AllowedID;
 }
 public static void RegisterWellKnownServiceType(Type type, string objectUri, WellKnownObjectMode mode)
 {
   Contract.Requires(type.Module != null);
   Contract.Requires(type.Module.Assembly != null);
   Contract.Ensures(type.Module.Assembly != null);
 }
Example #47
0
    }//GetOptions()

    /// <summary>
    /// Runs this program as a server.
    /// </summary>
    public static void Run(ChannelKind ChanKind, WellKnownObjectMode ObjMode, Type ObjType)
    {
      TcpChannel tcpchan;
      HttpChannel httpchan;

      Console.WriteLine("\nStarting server in WellKnownObjectMode {0}\n", ObjMode.ToString());

      switch (ChanKind)
      {
        case ChannelKind.Http:
          httpchan = new HttpChannel(Server.HTTPPORT);
          ChannelServices.RegisterChannel(httpchan);
          break;
        case ChannelKind.TCP:
          tcpchan = new TcpChannel(Server.TCPPORT);
          ChannelServices.RegisterChannel(tcpchan);
          break;
        case ChannelKind.Both:
          httpchan = new HttpChannel(Server.HTTPPORT);
          ChannelServices.RegisterChannel(httpchan);
          tcpchan = new TcpChannel(Server.TCPPORT);
          ChannelServices.RegisterChannel(tcpchan);
          break;
        default:
          throw new System.InvalidOperationException("Unexpected Channel kind in Server.Run()");
      }//switch
      
      RemotingConfiguration.RegisterWellKnownServiceType(ObjType, 
                                                         "SayHello", 
                                                         ObjMode);

      System.Console.WriteLine("Hit <enter> to exit...");
      System.Console.ReadLine();
      return;
    }
Example #48
0
    }//Usage()

    /// <summary>
    /// Determines whether to act as client or server and executes the relevant method.
    /// </summary>
    
    private static void GetOptions()
    {
GetChannel:
      Console.Write("\nHttp (h), TCP (t) or both (b)? ");
      string Reply = Console.ReadLine();
      switch (Reply.ToLower())
      {
        case "b":
          m_ChanKind = ChannelKind.Both;
          break;
        case "h":
          m_ChanKind = ChannelKind.Http;
          break;
        case "t":
          m_ChanKind = ChannelKind.TCP;
          break;
        default:
          Console.WriteLine("Invalid option, please try again.");
          goto GetChannel;
      }//switch

GetObjectMode:
        Console.Write("\nSingleCall (sc) or Singleton (st)? ");
      Reply = Console.ReadLine();
      switch (Reply.ToLower())
      {
        case "sc":
          m_ObjMode = WellKnownObjectMode.SingleCall;
          break;
        case "st":
          m_ObjMode = WellKnownObjectMode.Singleton;
          break;
        default:
          Console.WriteLine("Invalid option, please try again.");
          goto GetObjectMode;
      }//switch

GetConvention:
      Console.Write("\nBy ref (r) or by val (v)? ");
      Reply = Console.ReadLine();
      switch (Reply.ToLower())
      {
        case "r":
          m_CallConv = CallingConvention.ByRef;
          break;
        case "v":
          m_CallConv = CallingConvention.ByVal;
          break;
        default:
          Console.WriteLine("Invalid option, please try again.");
          goto GetConvention;
      }//switch
      return;
    }//GetOptions()
Example #49
0
 [System.Security.SecurityCritical]  // auto-generated
 internal ServerIdentity StartupWellKnownObject(
     String asmName, String svrTypeName, String URI, 
     WellKnownObjectMode mode)
 {
     return StartupWellKnownObject(asmName, svrTypeName, URI, mode, false);
 }
 public WellKnownServiceTypeEntry(Type type, string objectUri, WellKnownObjectMode mode)
 {
   Contract.Requires(type.Module != null);
   Contract.Requires(type.Module.Assembly != null);
   Contract.Ensures(type.Module.Assembly != null);
 }
Example #51
0
            [System.Security.SecurityCritical]  // auto-generated
            internal ServerIdentity StartupWellKnownObject( 
                String asmName, String svrTypeName, String URI, 
                WellKnownObjectMode mode,
                bool fReplace) 
            {
                lock (s_wkoStartLock)
                {
                    MarshalByRefObject obj = null; 
                    ServerIdentity srvID = null;
 
                    // attempt to load the type 
                    Type serverType = LoadType(svrTypeName, asmName);
 
                    // make sure the well known object derives from MarshalByRefObject
                    if(!serverType.IsMarshalByRef)
                    {
                        throw new RemotingException( 
                            Environment.GetResourceString("Remoting_WellKnown_MustBeMBR",
                            svrTypeName)); 
                    } 

                    // make sure that no one beat us to creating 
                    // the well known object
                    srvID = (ServerIdentity)IdentityHolder.ResolveIdentity(URI);
                    if ((srvID != null) && srvID.IsRemoteDisconnected())
                    { 
                        IdentityHolder.RemoveIdentity(URI);
                        srvID = null; 
                    } 

                    if (srvID == null) 
                    {
                        //WellKnown type instances need to be created under full trust
                        //since the permission set might have been restricted by the channel
                        //pipeline. 
                        //This assert is protected by Infrastructure link demands.
                        s_fullTrust.Assert(); 
                        try { 
                            obj = (MarshalByRefObject)Activator.CreateInstance(serverType, true);
 
                            if (RemotingServices.IsClientProxy(obj))
                            {
                                // The wellknown type is remoted so we must wrap the proxy
                                // with a local object. 

                                // The redirection proxy masquerades as an object of the appropriate 
                                // type, and forwards incoming messages to the actual proxy. 
                                RedirectionProxy redirectedProxy = new RedirectionProxy(obj, serverType);
                                redirectedProxy.ObjectMode = mode; 
                                RemotingServices.MarshalInternal(redirectedProxy, URI, serverType);

                                srvID = (ServerIdentity)IdentityHolder.ResolveIdentity(URI);
                                Contract.Assert(null != srvID, "null != srvID"); 

                                // The redirection proxy handles SingleCall versus Singleton, 
                                // so we always set its mode to Singleton. 
                                srvID.SetSingletonObjectMode();
                            } 
                            else
                            if (serverType.IsCOMObject && (mode == WellKnownObjectMode.Singleton))
                            {
                                // Singleton COM objects are wrapped, so that they will be 
                                //   recreated when an RPC server not available is thrown
                                //   if dllhost.exe is killed. 
                                ComRedirectionProxy comRedirectedProxy = new ComRedirectionProxy(obj, serverType); 
                                RemotingServices.MarshalInternal(comRedirectedProxy, URI, serverType);
 
                                srvID = (ServerIdentity)IdentityHolder.ResolveIdentity(URI);
                                Contract.Assert(null != srvID, "null != srvID");

                                // Only singleton COM objects are redirected this way. 
                                srvID.SetSingletonObjectMode();
                            } 
                            else 
                            {
                                // make sure the object didn't Marshal itself. 
                                String tempUri = RemotingServices.GetObjectUri(obj);
                                if (tempUri != null)
                                {
                                    throw new RemotingException( 
                                        String.Format(
                                            CultureInfo.CurrentCulture, Environment.GetResourceString( 
                                                "Remoting_WellKnown_CtorCantMarshal"), 
                                            URI));
                                } 

                                RemotingServices.MarshalInternal(obj, URI, serverType);

                                srvID = (ServerIdentity)IdentityHolder.ResolveIdentity(URI); 
                                Contract.Assert(null != srvID, "null != srvID");
 
                                if (mode == WellKnownObjectMode.SingleCall) 
                                {
                                    // We need to set a special flag in the serverId 
                                    // so that every dispatch to this type creates
                                    // a new instance of the server object
                                    srvID.SetSingleCallObjectMode();
                                } 
                                else
                                { 
                                    srvID.SetSingletonObjectMode(); 
                                }
                            } 
                        }
                        catch
                        {
                            throw; 
                        }
                        finally { 
                            SecurityPermission.RevertAssert(); 
                        }
                    } 

                    Contract.Assert(null != srvID, "null != srvID");
                    return srvID;
                } 
            } // StartupWellKnownObject
 public WellKnownServiceTypeEntry(String typeName, String assemblyName, String objectUri,
                                  WellKnownObjectMode mode)
 {
     if (typeName == null)
         throw new ArgumentNullException("typeName");
     if (assemblyName == null)
         throw new ArgumentNullException("assemblyName");
     if (objectUri == null)
         throw new ArgumentNullException("objectUri");
     Contract.EndContractBlock();
 
     TypeName = typeName;
     AssemblyName = assemblyName;
     _objectUri = objectUri;
     _mode = mode;
 }
        public WellKnownServiceTypeEntry(Type type, String objectUri, WellKnownObjectMode mode)
        {
            if (type == null)
                throw new ArgumentNullException("type");
            if (objectUri == null)
                throw new ArgumentNullException("objectUri");
            Contract.EndContractBlock();
        
            if (!(type is RuntimeType))
                throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"));

            TypeName = type.FullName;
            AssemblyName = type.Module.Assembly.FullName;
            _objectUri = objectUri;
            _mode = mode;
        }
Example #54
0
 /// <include file='doc\RemotingConfiguration.uex' path='docs/doc[@for="WellKnownServiceTypeEntry.WellKnownServiceTypeEntry1"]/*' />
 public WellKnownServiceTypeEntry(Type type, String objectUri, WellKnownObjectMode mode)
 {
     if (type == null)
         throw new ArgumentNullException("type");
     if (objectUri == null)
         throw new ArgumentNullException("objectUri");
 
     TypeName = type.FullName;
     AssemblyName = type.Module.Assembly.nGetSimpleName();
     _objectUri = objectUri;
     _mode = mode;
 }
 internal ServerIdentity StartupWellKnownObject(string asmName, string svrTypeName, string URI, WellKnownObjectMode mode, bool fReplace)
 {
     lock (s_wkoStartLock)
     {
         MarshalByRefObject obj2 = null;
         ServerIdentity identity = null;
         Type type = LoadType(svrTypeName, asmName);
         if (!type.IsMarshalByRef)
         {
             throw new RemotingException(Environment.GetResourceString("Remoting_WellKnown_MustBeMBR", new object[] { svrTypeName }));
         }
         identity = (ServerIdentity) IdentityHolder.ResolveIdentity(URI);
         if ((identity != null) && identity.IsRemoteDisconnected())
         {
             IdentityHolder.RemoveIdentity(URI);
             identity = null;
         }
         if (identity == null)
         {
             s_fullTrust.Assert();
             try
             {
                 obj2 = (MarshalByRefObject) Activator.CreateInstance(type, true);
                 if (RemotingServices.IsClientProxy(obj2))
                 {
                     RedirectionProxy proxy = new RedirectionProxy(obj2, type) {
                         ObjectMode = mode
                     };
                     RemotingServices.MarshalInternal(proxy, URI, type);
                     identity = (ServerIdentity) IdentityHolder.ResolveIdentity(URI);
                     identity.SetSingletonObjectMode();
                 }
                 else if (type.IsCOMObject && (mode == WellKnownObjectMode.Singleton))
                 {
                     ComRedirectionProxy proxy2 = new ComRedirectionProxy(obj2, type);
                     RemotingServices.MarshalInternal(proxy2, URI, type);
                     identity = (ServerIdentity) IdentityHolder.ResolveIdentity(URI);
                     identity.SetSingletonObjectMode();
                 }
                 else
                 {
                     if (RemotingServices.GetObjectUri(obj2) != null)
                     {
                         throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_WellKnown_CtorCantMarshal"), new object[] { URI }));
                     }
                     RemotingServices.MarshalInternal(obj2, URI, type);
                     identity = (ServerIdentity) IdentityHolder.ResolveIdentity(URI);
                     if (mode == WellKnownObjectMode.SingleCall)
                     {
                         identity.SetSingleCallObjectMode();
                     }
                     else
                     {
                         identity.SetSingletonObjectMode();
                     }
                 }
             }
             catch
             {
                 throw;
             }
             finally
             {
                 CodeAccessPermission.RevertAssert();
             }
         }
         return identity;
     }
 }
Example #56
0
 internal ServerWellKnownEntry AddServerWellKnownEntry(String typeName, String assemName,
     ArrayList contextAttributes, String objURI, WellKnownObjectMode objMode)
 {
     TryToLoadTypeIfApplicable(typeName, assemName);
     ServerWellKnownEntry swke = new ServerWellKnownEntry(typeName, assemName,
         contextAttributes, objURI, objMode);
     ServerWellKnownEntries.Add(swke);
     return swke;
 }    
 internal ServerWellKnownEntry(string typeName, string assemName, ArrayList contextAttributes, string objURI, WellKnownObjectMode objMode) : base(typeName, assemName, contextAttributes)
 {
     this.ObjectURI = objURI;
     this.ObjectMode = objMode;
 }
 public WellKnownServiceTypeEntry(Type type, string objectUri, WellKnownObjectMode mode)
 {
 }
Example #59
0
            [System.Security.SecurityCritical]  // auto-generated
            internal ServerIdentity StartupWellKnownObject(
                String asmName, String svrTypeName, String URI, 
                WellKnownObjectMode mode,
                bool fReplace)
            {
                lock (s_wkoStartLock)
                {                
                    MarshalByRefObject obj = null;
                    ServerIdentity srvID = null;

                    // attempt to load the type                
                    Type serverType = LoadType(svrTypeName, asmName);
                
                    // make sure the well known object derives from MarshalByRefObject
                    if(!serverType.IsMarshalByRef)
                    {   
                        throw new RemotingException(
                            Environment.GetResourceString("Remoting_WellKnown_MustBeMBR",
                            svrTypeName));                         
                    }

                    // make sure that no one beat us to creating
                    // the well known object
                    srvID = (ServerIdentity)IdentityHolder.ResolveIdentity(URI);
                    if ((srvID != null) && srvID.IsRemoteDisconnected())
                    {
                        IdentityHolder.RemoveIdentity(URI);
                        srvID = null;
                    }
                                        
                    if (srvID == null)
                    {                    
                        //WellKnown type instances need to be created under full trust
                        //since the permission set might have been restricted by the channel 
                        //pipeline.           
                        //This assert is protected by Infrastructure link demands.
                        s_fullTrust.Assert();                
                        try {                    
                            obj = (MarshalByRefObject)Activator.CreateInstance(serverType, true);
                                                 
                            if (RemotingServices.IsClientProxy(obj))
                            {
                                // The wellknown type is remoted so we must wrap the proxy
                                // with a local object.

                                // The redirection proxy masquerades as an object of the appropriate
                                // type, and forwards incoming messages to the actual proxy.
                                RedirectionProxy redirectedProxy = new RedirectionProxy(obj, serverType);
                                redirectedProxy.ObjectMode = mode;

                                // DevDiv 720951 and 911924:
                                // 'isInitializing' is propagated into the new ServerIdentity so that other concurrent
                                // operations that find it in URITable do not use it prematurely.
                                RemotingServices.MarshalInternal(redirectedProxy, URI, serverType, updateChannelData: true, isInitializing: true);

                                srvID = (ServerIdentity)IdentityHolder.ResolveIdentity(URI);
                                Contract.Assert(null != srvID, "null != srvID");

                                // The redirection proxy handles SingleCall versus Singleton,
                                // so we always set its mode to Singleton.
                                srvID.SetSingletonObjectMode();
                            }
                            else
                            if (serverType.IsCOMObject && (mode == WellKnownObjectMode.Singleton))
                            {
                                // Singleton COM objects are wrapped, so that they will be
                                //   recreated when an RPC server not available is thrown
                                //   if dllhost.exe is killed.
                                ComRedirectionProxy comRedirectedProxy = new ComRedirectionProxy(obj, serverType);

                                // DevDiv 720951 and 911924: isInitializing = true
                                RemotingServices.MarshalInternal(comRedirectedProxy, URI, serverType, updateChannelData: true, isInitializing: true);

                                srvID = (ServerIdentity)IdentityHolder.ResolveIdentity(URI);
                                Contract.Assert(null != srvID, "null != srvID");

                                // Only singleton COM objects are redirected this way.
                                srvID.SetSingletonObjectMode();
                            }
                            else
                            {
                                // make sure the object didn't Marshal itself.
                                String tempUri = RemotingServices.GetObjectUri(obj);
                                if (tempUri != null)
                                {
                                    throw new RemotingException(
                                        String.Format(
                                            CultureInfo.CurrentCulture, Environment.GetResourceString(
                                                "Remoting_WellKnown_CtorCantMarshal"),
                                            URI));
                                }

                                // DevDiv 720951 and 911924: isInitializing = true
                                RemotingServices.MarshalInternal(obj, URI, serverType, updateChannelData: true, isInitializing: true);

                                srvID = (ServerIdentity)IdentityHolder.ResolveIdentity(URI);
                                Contract.Assert(null != srvID, "null != srvID");

                                if (mode == WellKnownObjectMode.SingleCall)
                                {
                                    // We need to set a special flag in the serverId
                                    // so that every dispatch to this type creates 
                                    // a new instance of the server object
                                    srvID.SetSingleCallObjectMode();
                                }
                                else
                                {
                                    srvID.SetSingletonObjectMode();
                                }
                            }

                        }
                        catch
                        {
                            // DevDiv 720951 and 911924:
                            // An exception thrown in the scope of this attempt to create a
                            // new ServerIdentity may leave a ServerIdentity instance in the
                            // URITable that has not been properly initialized.  This condition
                            // has been true for all versions of the framework but was first
                            // recognized in making this fix in 4.5.3.  Ideally, a damaged
                            // ServerIdentity should be removed from URITable.  But due to risk
                            // and lack of customer reports of a problem, we chose not to fix it.
                            throw;
                        }
                        finally {

                            // DevDiv 720951 and 911924:
                            // This flag is cleared only after the new ServerIdentity is completely
                            // initialized and ready for use.  It is done here in the 'finally' to
                            // ensure all exit paths reset the flag, including exceptions.
                            if (srvID != null)
                            {
                                srvID.IsInitializing = false;
                            }

                            SecurityPermission.RevertAssert();
                        }
                    }
                    
                    Contract.Assert(null != srvID, "null != srvID");
                    return srvID;
                }
            } // StartupWellKnownObject
 // Constructors
 public WellKnownServiceTypeEntry(string typeName, string assemblyName, string objectUri, WellKnownObjectMode mode)
 {
 }