internal static ServerIdentity FindOrCreateServerIdentity(MarshalByRefObject obj, string objURI, int flags)
        {
            ServerIdentity idObj = null;
            bool           flag;

            idObj = (ServerIdentity)MarshalByRefObject.GetIdentity(obj, out flag);
            if (idObj == null)
            {
                Context serverCtx = null;
                if (obj is ContextBoundObject)
                {
                    serverCtx = Thread.CurrentContext;
                }
                else
                {
                    serverCtx = DefaultContext;
                }
                ServerIdentity id = new ServerIdentity(obj, serverCtx);
                if (flag)
                {
                    idObj = obj.__RaceSetServerIdentity(id);
                }
                else
                {
                    RealProxy realProxy = null;
                    realProxy = RemotingServices.GetRealProxy(obj);
                    realProxy.IdentityObject = id;
                    idObj = (ServerIdentity)realProxy.IdentityObject;
                }
            }
            if (IdOps.bStrongIdentity(flags))
            {
                ReaderWriterLock tableLock = TableLock;
                bool             flag2     = !tableLock.IsWriterLockHeld;
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    if (flag2)
                    {
                        tableLock.AcquireWriterLock(0x7fffffff);
                    }
                    if ((idObj.ObjURI == null) || !idObj.IsInIDTable())
                    {
                        SetIdentity(idObj, objURI, DuplicateIdentityOption.Unique);
                    }
                    if (idObj.IsDisconnected())
                    {
                        idObj.SetFullyConnected();
                    }
                }
                finally
                {
                    if (flag2 && tableLock.IsWriterLockHeld)
                    {
                        tableLock.ReleaseWriterLock();
                    }
                }
            }
            return(idObj);
        }
Ejemplo n.º 2
0
        internal static bool RemoveDynamicProperty(MarshalByRefObject obj, String name)
        {
            if (RemotingServices.IsObjectOutOfContext(obj))
            {
                // We have to add a proxy side property, get the identity
                RealProxy rp = RemotingServices.GetRealProxy(obj);
                return(rp.IdentityObject.RemoveProxySideDynamicProperty(name));
            }
            else
            {
                MarshalByRefObject realObj =
                    (MarshalByRefObject)
                    RemotingServices.AlwaysUnwrap((ContextBoundObject)obj);

                // This is a real object. See if we have an identity for it
                ServerIdentity srvID = (ServerIdentity)MarshalByRefObject.GetIdentity(realObj);
                if (srvID != null)
                {
                    return(srvID.RemoveServerSideDynamicProperty(name));
                }
                else
                {
                    // identity not found, we can't set a sink for this object.
                    throw new RemotingException(
                              Environment.GetResourceString("Remoting_NoIdentityEntry"));
                }
            }
        }
 internal MethodCall(object handlerObject, BinaryMethodCallMessage smuggledMsg)
 {
     if (handlerObject != null)
     {
         this.uri = handlerObject as string;
         if (this.uri == null)
         {
             MarshalByRefObject obj2 = handlerObject as MarshalByRefObject;
             if (obj2 != null)
             {
                 bool flag;
                 this.srvID = MarshalByRefObject.GetIdentity(obj2, out flag) as ServerIdentity;
                 this.uri = this.srvID.URI;
             }
         }
     }
     this.typeName = smuggledMsg.TypeName;
     this.methodName = smuggledMsg.MethodName;
     this.methodSignature = (Type[]) smuggledMsg.MethodSignature;
     this.args = smuggledMsg.Args;
     this.instArgs = smuggledMsg.InstantiationArgs;
     this.callContext = smuggledMsg.LogicalCallContext;
     this.ResolveMethod();
     if (smuggledMsg.HasProperties)
     {
         smuggledMsg.PopulateMessageProperties(this.Properties);
     }
 }
Ejemplo n.º 4
0
        internal static IEnvoyInfo CreateEnvoyInfo(ServerIdentity serverID)
        {
            IEnvoyInfo info = null;

            if (null != serverID)
            {
                // Set the envoy sink chain
                if (serverID.EnvoyChain == null)
                {
                    serverID.RaceSetEnvoyChain(
                        serverID.ServerContext.CreateEnvoyChain(
                            serverID.TPOrObject));
                }

                // Create an envoy info object only if necessary
                IMessageSink sink = serverID.EnvoyChain as EnvoyTerminatorSink;
                if (null == sink)
                {
                    // The chain consists of more than a terminator sink
                    // Go ahead and create an envoy info structure, otherwise
                    // a null is returned and we recreate the terminator sink
                    // on the other side, automatically.
                    info = new EnvoyInfo(serverID.EnvoyChain);
                }
            }

            return(info);
        }
Ejemplo n.º 5
0
		public void StopTrackingLifetime (ServerIdentity identity)
		{
			lock (_objects.SyncRoot)
			{
				_objects.Remove (identity);
			}
		}
Ejemplo n.º 6
0
        public static bool IsObjectOutOfContext(object tp)
        {
            MarshalByRefObject mbr = tp as MarshalByRefObject;

            if (mbr == null)
            {
                return(false);
            }

            // TODO: use internal call for better performance
            Identity ident = GetObjectIdentity(mbr);

            if (ident == null)
            {
                return(false);
            }

            ServerIdentity sident = ident as ServerIdentity;

            if (sident != null)
            {
                return(sident.Context != System.Threading.Thread.CurrentContext);
            }
            else
            {
                return(true);
            }
        }
 internal AsyncWorkItem(IMessage reqMsg, IMessageSink replySink, Context oldCtx, ServerIdentity srvID)
 {
     this._reqMsg = reqMsg;
     this._replySink = replySink;
     this._oldCtx = oldCtx;
     this._callCtx = CallContext.GetLogicalCallContext();
     this._srvID = srvID;
 }
Ejemplo n.º 8
0
		public void TrackLifetime (ServerIdentity identity)
		{
			lock (_objects.SyncRoot)
			{
				identity.Lease.Activate();
				_objects.Add (identity);

				if (_timer == null) StartManager();
			}
		}
Ejemplo n.º 9
0
        public static Type GetServerTypeForUri(string URI)
        {
            ServerIdentity ident = GetIdentityForUri(URI) as ServerIdentity;

            if (ident == null)
            {
                return(null);
            }
            return(ident.ObjectType);
        }
Ejemplo n.º 10
0
        internal static ServerIdentity FindOrCreateServerIdentity(MarshalByRefObject obj, string objURI, int flags)
        {
            bool           fServer;
            ServerIdentity serverIdentity1 = (ServerIdentity)MarshalByRefObject.GetIdentity(obj, out fServer);

            if (serverIdentity1 == null)
            {
                Context        serverCtx = !(obj is ContextBoundObject) ? IdentityHolder.DefaultContext : Thread.CurrentContext;
                ServerIdentity id        = new ServerIdentity(obj, serverCtx);
                if (fServer)
                {
                    serverIdentity1 = obj.__RaceSetServerIdentity(id);
                }
                else
                {
                    RealProxy      realProxy       = RemotingServices.GetRealProxy((object)obj);
                    ServerIdentity serverIdentity2 = id;
                    realProxy.IdentityObject = (Identity)serverIdentity2;
                    serverIdentity1          = (ServerIdentity)realProxy.IdentityObject;
                }
                if (IdOps.bIsInitializing(flags))
                {
                    serverIdentity1.IsInitializing = true;
                }
            }
            if (IdOps.bStrongIdentity(flags))
            {
                ReaderWriterLock tableLock = IdentityHolder.TableLock;
                bool             flag      = !tableLock.IsWriterLockHeld;
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    if (flag)
                    {
                        tableLock.AcquireWriterLock(int.MaxValue);
                    }
                    if (serverIdentity1.ObjURI == null || !serverIdentity1.IsInIDTable())
                    {
                        IdentityHolder.SetIdentity((Identity)serverIdentity1, objURI, DuplicateIdentityOption.Unique);
                    }
                    if (serverIdentity1.IsDisconnected())
                    {
                        serverIdentity1.SetFullyConnected();
                    }
                }
                finally
                {
                    if (flag && tableLock.IsWriterLockHeld)
                    {
                        tableLock.ReleaseWriterLock();
                    }
                }
            }
            return(serverIdentity1);
        }
Ejemplo n.º 11
0
        private static void RegisterServerIdentity(ServerIdentity identity)
        {
            lock (uri_hash)
            {
                if (uri_hash.ContainsKey(identity.ObjectUri))
                {
                    throw new RemotingException("Uri already in use: " + identity.ObjectUri + ".");
                }

                uri_hash[identity.ObjectUri] = identity;
            }
        }
 internal ServerIdentity __RaceSetServerIdentity(ServerIdentity id)
 {
     if (this.__identity == null)
     {
         if (!id.IsContextBound)
         {
             id.RaceSetTransparentProxy(this);
         }
         Interlocked.CompareExchange(ref this.__identity, id, null);
     }
     return (ServerIdentity) this.__identity;
 }
            internal ServerIdentity StartupWellKnownObject(string URI)
            {
                string                    str      = URI.ToLower(CultureInfo.InvariantCulture);
                ServerIdentity            identity = null;
                WellKnownServiceTypeEntry entry    = (WellKnownServiceTypeEntry)this._wellKnownExportInfo[str];

                if (entry != null)
                {
                    identity = this.StartupWellKnownObject(entry.AssemblyName, entry.TypeName, entry.ObjectUri, entry.Mode);
                }
                return(identity);
            }
 internal TransitionCall(IntPtr targetCtxID, CrossContextDelegate deleg)
 {
     this._sourceCtxID = Thread.CurrentContext.InternalContextID;
     this._targetCtxID = targetCtxID;
     this._delegate = deleg;
     this._targetDomainID = 0;
     this._eeData = IntPtr.Zero;
     this._srvID = new ServerIdentity(null, Thread.GetContextInternal(this._targetCtxID));
     this._ID = this._srvID;
     this._ID.RaceSetChannelSink(CrossContextChannel.MessageSink);
     this._srvID.RaceSetServerObjectChain(this);
 }
Ejemplo n.º 15
0
        internal static bool RemoveDynamicProperty(MarshalByRefObject obj, string name)
        {
            if (RemotingServices.IsObjectOutOfContext((object)obj))
            {
                return(RemotingServices.GetRealProxy((object)obj).IdentityObject.RemoveProxySideDynamicProperty(name));
            }
            ServerIdentity serverIdentity = (ServerIdentity)MarshalByRefObject.GetIdentity((MarshalByRefObject)RemotingServices.AlwaysUnwrap((ContextBoundObject)obj));

            if (serverIdentity != null)
            {
                return(serverIdentity.RemoveServerSideDynamicProperty(name));
            }
            throw new RemotingException(Environment.GetResourceString("Remoting_NoIdentityEntry"));
        }
 internal TransitionCall(IntPtr targetCtxID, IntPtr eeData, int targetDomainID)
 {
     string str;
     this._sourceCtxID = Thread.CurrentContext.InternalContextID;
     this._targetCtxID = targetCtxID;
     this._delegate = null;
     this._targetDomainID = targetDomainID;
     this._eeData = eeData;
     this._srvID = null;
     this._ID = new Identity("TransitionCallURI", null);
     CrossAppDomainData data = new CrossAppDomainData(this._targetCtxID, this._targetDomainID, Identity.ProcessGuid);
     IMessageSink channelSink = CrossAppDomainChannel.AppDomainChannel.CreateMessageSink(null, data, out str);
     this._ID.RaceSetChannelSink(channelSink);
 }
        internal static bool AddDynamicProperty(MarshalByRefObject obj, IDynamicProperty prop)
        {
            if (RemotingServices.IsObjectOutOfContext(obj))
            {
                return(RemotingServices.GetRealProxy(obj).IdentityObject.AddProxySideDynamicProperty(prop));
            }
            MarshalByRefObject obj2     = (MarshalByRefObject)RemotingServices.AlwaysUnwrap((ContextBoundObject)obj);
            ServerIdentity     identity = (ServerIdentity)MarshalByRefObject.GetIdentity(obj2);

            if (identity == null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_NoIdentityEntry"));
            }
            return(identity.AddServerSideDynamicProperty(prop));
        }
Ejemplo n.º 18
0
        internal static IEnvoyInfo CreateEnvoyInfo(ServerIdentity serverID)
        {
            IEnvoyInfo result = null;

            if (serverID != null)
            {
                if (serverID.EnvoyChain == null)
                {
                    serverID.RaceSetEnvoyChain(serverID.ServerContext.CreateEnvoyChain(serverID.TPOrObject));
                }
                if (!(serverID.EnvoyChain is EnvoyTerminatorSink))
                {
                    result = new EnvoyInfo(serverID.EnvoyChain);
                }
            }
            return(result);
        }
Ejemplo n.º 19
0
        } // DumpIdentities

        internal static Identity DumpIdentity(String idUri)
        {
            // We don't want to take locks. This will only be called from the debugger.
            // To use from cordbg:
            //   newstr "object-uri"
            //   f System.Runtime.Remoting.IdentityHolder::DumpIdentity $result

            Object obj = _URITable[MakeURIKey(idUri)];

            Identity id = null;

            if (obj is WeakReference)
            {
                id = ((WeakReference)obj).Target as Identity;
            }
            else
            {
                id = obj as Identity;
            }

            if (id != null)
            {
                Console.Error.WriteLine("Identity: " + idUri);

                String uri = id.URI;

                ServerIdentity srvId = id as ServerIdentity;
                if (srvId != null)
                {
                    Console.Error.WriteLine("\tserver: " + srvId.ServerType + "; uri = <" + uri + ">");
                }
                else
                {
                    Console.Error.WriteLine("\tclient: uri = <" + uri + ">");
                }
            }
            else
            {
                Console.Error.WriteLine("No identity found: " + idUri);
            }


            return(id);
        } // DumpIdentity
Ejemplo n.º 20
0
        internal static IEnvoyInfo CreateEnvoyInfo(ServerIdentity serverID)
        {
            IEnvoyInfo envoyInfo = (IEnvoyInfo)null;

            if (serverID != null)
            {
                if (serverID.EnvoyChain == null)
                {
                    ServerIdentity serverIdentity = serverID;
                    IMessageSink   envoyChain     = serverIdentity.ServerContext.CreateEnvoyChain(serverID.TPOrObject);
                    serverIdentity.RaceSetEnvoyChain(envoyChain);
                }
                if ((IMessageSink)(serverID.EnvoyChain as EnvoyTerminatorSink) == null)
                {
                    envoyInfo = (IEnvoyInfo) new EnvoyInfo(serverID.EnvoyChain);
                }
            }
            return(envoyInfo);
        }
 internal static object ActivateWithMessage(Type serverType, IMessage msg, ServerIdentity srvIdToBind, out Exception e)
 {
     object obj2 = null;
     e = null;
     obj2 = RemotingServices.AllocateUninitializedObject(serverType);
     object proxy = null;
     if (serverType.IsContextful)
     {
         if (msg is ConstructorCallMessage)
         {
             proxy = ((ConstructorCallMessage) msg).GetThisPtr();
         }
         else
         {
             proxy = null;
         }
         proxy = RemotingServices.Wrap((ContextBoundObject) obj2, proxy, false);
     }
     else
     {
         if (Thread.CurrentContext != Context.DefaultContext)
         {
             throw new RemotingException(Environment.GetResourceString("Remoting_Activation_Failed"));
         }
         proxy = obj2;
     }
     IMessageSink sink = new StackBuilderSink(proxy);
     IMethodReturnMessage message = (IMethodReturnMessage) sink.SyncProcessMessage(msg);
     if (message.Exception == null)
     {
         if (serverType.IsContextful)
         {
             return RemotingServices.Wrap((ContextBoundObject) obj2);
         }
         return obj2;
     }
     e = message.Exception;
     return null;
 }
Ejemplo n.º 22
0
        //
        // DEBUG Helpers
        //   Note: These methods should be included even in retail builds so that
        //     they can be called from the debugger.
        //

        internal static void DumpIdentities()
        {
            // We don't want to take locks. This will only be called from the debugger.
            // To use from cordbg:
            //   f System.Runtime.Remoting.IdentityHolder::DumpIdentities

            Console.Error.WriteLine("Identity Table:");

            foreach (DictionaryEntry entry in _URITable)
            {
                Object obj = entry.Value;

                Identity id = null;
                if (obj is WeakReference)
                {
                    id = ((WeakReference)obj).Target as Identity;
                }
                else
                {
                    id = obj as Identity;
                }

                if (id != null)
                {
                    String uri = id.URI;

                    ServerIdentity srvId = id as ServerIdentity;
                    if (srvId != null)
                    {
                        Console.Error.WriteLine("server: " + srvId.ServerType + "; uri = <" + uri + ">");
                    }
                    else
                    {
                        Console.Error.WriteLine("client: uri = <" + uri + ">");
                    }
                }
            }
        } // DumpIdentities
Ejemplo n.º 23
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static ServerIdentity FindOrCreateServerIdentity(
            MarshalByRefObject obj, String objURI, int flags)
        {
            Message.DebugOut("Entered FindOrCreateServerIdentity \n");

            ServerIdentity srvID = null;

            bool fServer;

            srvID = (ServerIdentity)MarshalByRefObject.GetIdentity(obj, out fServer);

            if (srvID == null)
            {
                // Create a new server identity and add it to the
                // table. IdentityHolder will take care of ----s
                Context serverCtx = null;

                if (obj is ContextBoundObject)
                {
                    serverCtx = Thread.CurrentContext;
                }
                else
                {
                    serverCtx = DefaultContext;
                }
                Contract.Assert(null != serverCtx, "null != serverCtx");

                ServerIdentity serverID = new ServerIdentity(obj, serverCtx);

                // Set the identity depending on whether we have the server or proxy
                if (fServer)
                {
                    srvID = obj.__RaceSetServerIdentity(serverID);
                    Contract.Assert(srvID == MarshalByRefObject.GetIdentity(obj), "Bad ID state!");
                }
                else
                {
                    RealProxy rp = null;
                    rp = RemotingServices.GetRealProxy(obj);
                    Contract.Assert(null != rp, "null != rp");

                    rp.IdentityObject = serverID;
                    srvID             = (ServerIdentity)rp.IdentityObject;
                }

                // DevDiv 720951 and 911924:
                // CreateWellKnownObject creates a ServerIdentity and places it in URITable
                // before it is fully initialized.  This transient flag is set to to prevent
                // other concurrent operations from using it.  CreateWellKnownObject is the
                // only code path that sets this flag, and by default it is false.
                if (IdOps.bIsInitializing(flags))
                {
                    srvID.IsInitializing = true;
                }

                Message.DebugOut("Created ServerIdentity \n");
            }

#if false
            // Check that we are asked to create the identity for the same
            // URI as the one already associated with the server object.
            // It is an error to associate two URIs with the same server
            // object
            // GopalK: Try eliminating the test because it is also done by GetOrCreateIdentity
            if ((null != objURI) && (null != srvID.ObjURI))
            {
                if (string.Compare(objURI, srvID.ObjURI, StringComparison.OrdinalIgnoreCase) == 0) // case-insensitive compare
                {
                    Message.DebugOut("Trying to associate a URI with identity again .. throwing execption \n");
                    throw new RemotingException(
                              String.Format(
                                  Environment.GetResourceString(
                                      "Remoting_ResetURI"),
                                  srvID.ObjURI, objURI));
                }
            }
#endif

            // NOTE: for purely x-context cases we never execute this ...
            // the server ID is not put in the ID table.
            if (IdOps.bStrongIdentity(flags))
            {
                // We need to guarantee that finally is not interrupted so that the lock is released.
                // TableLock has a long path without reliability contract.  To avoid adding contract on
                // the path, we will use ReaderWriterLock directly.
                ReaderWriterLock rwlock         = TableLock;
                bool             takeAndRelease = !rwlock.IsWriterLockHeld;

                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    if (takeAndRelease)
                    {
                        rwlock.AcquireWriterLock(INFINITE);
                    }

                    // It is possible that we are marshaling out of this app-domain
                    // for the first time. We need to do two things
                    // (1) If there is no URI associated with the identity then go ahead
                    // and generate one.
                    // (2) Add the identity to the URI -> Identity map if not already present
                    // (For purely x-context cases we don't need the URI)
                    // (3) If the object ref is null, then this object hasn't been
                    // marshalled yet.
                    // (4) if id was created through SetObjectUriForMarshal, it would be
                    // in the ID table
                    if ((srvID.ObjURI == null) ||
                        (srvID.IsInIDTable() == false))
                    {
                        // we are marshalling a server object, so there should not be a
                        //   a different identity at this location.
                        SetIdentity(srvID, objURI, DuplicateIdentityOption.Unique);
                    }

                    // If the object is marked as disconnect, mark it as connected
                    if (srvID.IsDisconnected())
                    {
                        srvID.SetFullyConnected();
                    }
                }
                finally
                {
                    if (takeAndRelease && rwlock.IsWriterLockHeld)
                    {
                        rwlock.ReleaseWriterLock();
                    }
                }
            }

            Message.DebugOut("Leaving FindOrCreateServerIdentity \n");
            Contract.Assert(null != srvID, "null != srvID");
            return(srvID);
        }
 internal void InitFields(MessageData msgData)
 {
     this._frame = msgData.pFrame;
     this._delegateMD = msgData.pDelegateMD;
     this._methodDesc = msgData.pMethodDesc;
     this._flags = msgData.iFlags;
     this._initDone = true;
     this._metaSigHolder = msgData.pSig;
     this._governingType = msgData.thGoverningType;
     this._MethodName = null;
     this._MethodSignature = null;
     this._MethodBase = null;
     this._URI = null;
     this._Fault = null;
     this._ID = null;
     this._srvID = null;
     this._callContext = null;
     if (this._properties != null)
     {
         ((IDictionary) this._properties).Clear();
     }
 }
 [System.Security.SecurityCritical]  // auto-generated
 internal AsyncWorkItem(IMessage reqMsg, IMessageSink replySink, Context oldCtx, ServerIdentity srvID)
 {
     _reqMsg = reqMsg;
     _replySink = replySink;
     _oldCtx = oldCtx;
     _callCtx = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;
     _srvID = srvID;
 }
Ejemplo n.º 26
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static Object ActivateWithMessage(
            Type serverType, IMessage msg, ServerIdentity srvIdToBind,
            out Exception e)
        {
            Object server = null;
            e = null;

            // Create a blank instance!
            server = RemotingServices.AllocateUninitializedObject(serverType);

            Object proxyForObject = null;
            if (serverType.IsContextful)
            {
                if (msg is ConstructorCallMessage)
                {
                    // If it is a strictly x-context activation then
                    // this pointer for the message is the TP that we
                    // returned to JIT in first phase of activation
                    proxyForObject = ((ConstructorCallMessage)msg).GetThisPtr();
                }
                else
                {
                    // we are out of the app-domain, so wrap this object now
                    proxyForObject = null;
                }

                // This associates the proxy with the real object and sets
                // up the proxy's native context, ID etc.
                proxyForObject = RemotingServices.Wrap(
                                        (ContextBoundObject)server,
                                        proxyForObject, 
                                        false);
                Contract.Assert(
                    RemotingServices.IsTransparentProxy(proxyForObject),
                    "Wrapped object should be a transparent proxy");
            }
            else
            {
                // Since this is an MBR type, something really bad
                // happened if we are not in the default context
                if (Thread.CurrentContext != Context.DefaultContext)
                {
                    throw new RemotingException(
                        Environment.GetResourceString(
                            "Remoting_Activation_Failed"));
                }
                // Marshal-by-ref case we just return the object
                proxyForObject = server;                                
            }

            // Create the dispatcher which will help run the CTOR
            IMessageSink dispatcher = (IMessageSink)new StackBuilderSink(proxyForObject);

            // This call runs the CTOR on the object
            IMethodReturnMessage retMsg = (IMethodReturnMessage) 
                                        dispatcher.SyncProcessMessage(msg);

            if (retMsg.Exception == null)
            {
                if (serverType.IsContextful)
                {
                    // call wrap to finish the operation.
                    return RemotingServices.Wrap((ContextBoundObject)server);
                }
                else
                {
                    return server;
                }
            }
            else
            {
                e = retMsg.Exception;
                return null;
            }
        }
Ejemplo n.º 27
0
		private static void RegisterServerIdentity(ServerIdentity identity)
		{
			lock (uri_hash)
			{
				if (uri_hash.ContainsKey (identity.ObjectUri)) 
					throw new RemotingException ("Uri already in use: " + identity.ObjectUri + ".");

				uri_hash[identity.ObjectUri] = identity;
			}
		}
 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);
     }
 }
 internal Type ResolveType()
 {
     Type newType = null;
     if (this.srvID == null)
     {
         this.srvID = IdentityHolder.CasualResolveIdentity(this.uri) as ServerIdentity;
     }
     if (this.srvID != null)
     {
         Type lastCalledType = this.srvID.GetLastCalledType(this.typeName);
         if (lastCalledType != null)
         {
             return lastCalledType;
         }
         int startIndex = 0;
         if (string.CompareOrdinal(this.typeName, 0, "clr:", 0, 4) == 0)
         {
             startIndex = 4;
         }
         int index = this.typeName.IndexOf(',', startIndex);
         if (index == -1)
         {
             index = this.typeName.Length;
         }
         lastCalledType = this.srvID.ServerType;
         newType = ResolveTypeRelativeTo(this.typeName, startIndex, index - startIndex, lastCalledType);
     }
     if (newType == null)
     {
         newType = RemotingServices.InternalGetTypeFromQualifiedTypeName(this.typeName);
     }
     if (this.srvID != null)
     {
         this.srvID.SetLastCalledType(this.typeName, newType);
     }
     return newType;
 }
Ejemplo n.º 30
0
        } // CasualResolveReference

       //
       //
        // This is typically called when we need to create/establish
        // an identity for a serverObject.               
        internal static ServerIdentity FindOrCreateServerIdentity(
            MarshalByRefObject obj,  String objURI, int flags) 
        {
            Message.DebugOut("Entered FindOrCreateServerIdentity \n");
                    
            ServerIdentity srvID = null;
            bool bLock = false;

            try
            {
                bool fServer;
                srvID = (ServerIdentity) MarshalByRefObject.GetIdentity(obj, out fServer);

                if (srvID == null)
                {
                    // Create a new server identity and add it to the
                    // table. IdentityHolder will take care of races
                    Context serverCtx = null;
                    
                    if (obj is ContextBoundObject)
                    {
                        serverCtx = Thread.CurrentContext;
                    }
                    else
                    {
                        serverCtx = DefaultContext;
                    }
                    BCLDebug.Assert(null != serverCtx, "null != serverCtx");

                    ServerIdentity serverID = new ServerIdentity(obj, serverCtx);

                    // Set the identity depending on whether we have the server or proxy
                    if(fServer)
                    {
                        srvID = obj.__RaceSetServerIdentity(serverID);
                        BCLDebug.Assert(srvID == MarshalByRefObject.GetIdentity(obj), "Bad ID state!" );             
                    }
                    else
                    {
                        RealProxy rp = null;
                        rp = RemotingServices.GetRealProxy(obj);
                        BCLDebug.Assert(null != rp, "null != rp");

                        rp.IdentityObject = serverID;
                        srvID = (ServerIdentity) rp.IdentityObject;
                    }

                    Message.DebugOut("Created ServerIdentity \n");
                }


                // NOTE: for purely x-context cases we never execute this ...
                // the server ID is not put in the ID table. 
                if ( IdOps.bStrongIdentity(flags) )
                {

                    TableLock.AcquireWriterLock(INFINITE);
                    bLock = true;

                    // It is possible that we are marshaling out of this app-domain
                    // for the first time. We need to do two things
                    // (1) If there is no URI associated with the identity then go ahead 
                    // and generate one.
                    // (2) Add the identity to the URI -> Identity map if not already present
                    // (For purely x-context cases we don't need the URI)   
                    // (3) If the object ref is null, then this object hasn't been
                    // marshalled yet.
                    // (4) if id was created through SetObjectUriForMarshal, it would be
                    // in the ID table
                    if ((srvID.ObjURI == null) ||
                       (srvID.IsInIDTable() == false))
                    {
                        // we are marshalling a server object, so there should not be a
                        //   a different identity at this location.
                        SetIdentity(srvID, objURI, DuplicateIdentityOption.Unique);
                    }

                    // If the object is marked as disconnect, mark it as connected
                    if(srvID.IsDisconnected())
                            srvID.SetFullyConnected();
                }
            }
            finally
            {
                if (bLock)
                {
                    TableLock.ReleaseWriterLock();
                }
            }

            Message.DebugOut("Leaving FindOrCreateServerIdentity \n");
            BCLDebug.Assert(null != srvID,"null != srvID");
            return srvID;                
        }
 internal static ServerIdentity FindOrCreateServerIdentity(MarshalByRefObject obj, string objURI, int flags)
 {
     ServerIdentity idObj = null;
     bool flag;
     idObj = (ServerIdentity) MarshalByRefObject.GetIdentity(obj, out flag);
     if (idObj == null)
     {
         Context serverCtx = null;
         if (obj is ContextBoundObject)
         {
             serverCtx = Thread.CurrentContext;
         }
         else
         {
             serverCtx = DefaultContext;
         }
         ServerIdentity id = new ServerIdentity(obj, serverCtx);
         if (flag)
         {
             idObj = obj.__RaceSetServerIdentity(id);
         }
         else
         {
             RealProxy realProxy = null;
             realProxy = RemotingServices.GetRealProxy(obj);
             realProxy.IdentityObject = id;
             idObj = (ServerIdentity) realProxy.IdentityObject;
         }
     }
     if (IdOps.bStrongIdentity(flags))
     {
         ReaderWriterLock tableLock = TableLock;
         bool flag2 = !tableLock.IsWriterLockHeld;
         RuntimeHelpers.PrepareConstrainedRegions();
         try
         {
             if (flag2)
             {
                 tableLock.AcquireWriterLock(0x7fffffff);
             }
             if ((idObj.ObjURI == null) || !idObj.IsInIDTable())
             {
                 SetIdentity(idObj, objURI, DuplicateIdentityOption.Unique);
             }
             if (idObj.IsDisconnected())
             {
                 idObj.SetFullyConnected();
             }
         }
         finally
         {
             if (flag2 && tableLock.IsWriterLockHeld)
             {
                 tableLock.ReleaseWriterLock();
             }
         }
     }
     return idObj;
 }
Ejemplo n.º 32
0
        } // CasualResolveReference

        //
        //
        // This is typically called when we need to create/establish
        // an identity for a serverObject.
        internal static ServerIdentity FindOrCreateServerIdentity(
            MarshalByRefObject obj, String objURI, int flags)
        {
            Message.DebugOut("Entered FindOrCreateServerIdentity \n");

            ServerIdentity srvID = null;
            bool           bLock = false;

            try
            {
                bool fServer;
                srvID = (ServerIdentity)MarshalByRefObject.GetIdentity(obj, out fServer);

                if (srvID == null)
                {
                    // Create a new server identity and add it to the
                    // table. IdentityHolder will take care of races
                    Context serverCtx = null;

                    if (obj is ContextBoundObject)
                    {
                        serverCtx = Thread.CurrentContext;
                    }
                    else
                    {
                        serverCtx = DefaultContext;
                    }
                    BCLDebug.Assert(null != serverCtx, "null != serverCtx");

                    ServerIdentity serverID = new ServerIdentity(obj, serverCtx);

                    // Set the identity depending on whether we have the server or proxy
                    if (fServer)
                    {
                        srvID = obj.__RaceSetServerIdentity(serverID);
                        BCLDebug.Assert(srvID == MarshalByRefObject.GetIdentity(obj), "Bad ID state!");
                    }
                    else
                    {
                        RealProxy rp = null;
                        rp = RemotingServices.GetRealProxy(obj);
                        BCLDebug.Assert(null != rp, "null != rp");

                        rp.IdentityObject = serverID;
                        srvID             = (ServerIdentity)rp.IdentityObject;
                    }

                    Message.DebugOut("Created ServerIdentity \n");
                }


                // NOTE: for purely x-context cases we never execute this ...
                // the server ID is not put in the ID table.
                if (IdOps.bStrongIdentity(flags))
                {
                    TableLock.AcquireWriterLock(INFINITE);
                    bLock = true;

                    // It is possible that we are marshaling out of this app-domain
                    // for the first time. We need to do two things
                    // (1) If there is no URI associated with the identity then go ahead
                    // and generate one.
                    // (2) Add the identity to the URI -> Identity map if not already present
                    // (For purely x-context cases we don't need the URI)
                    // (3) If the object ref is null, then this object hasn't been
                    // marshalled yet.
                    // (4) if id was created through SetObjectUriForMarshal, it would be
                    // in the ID table
                    if ((srvID.ObjURI == null) ||
                        (srvID.IsInIDTable() == false))
                    {
                        // we are marshalling a server object, so there should not be a
                        //   a different identity at this location.
                        SetIdentity(srvID, objURI, DuplicateIdentityOption.Unique);
                    }

                    // If the object is marked as disconnect, mark it as connected
                    if (srvID.IsDisconnected())
                    {
                        srvID.SetFullyConnected();
                    }
                }
            }
            finally
            {
                if (bLock)
                {
                    TableLock.ReleaseWriterLock();
                }
            }

            Message.DebugOut("Leaving FindOrCreateServerIdentity \n");
            BCLDebug.Assert(null != srvID, "null != srvID");
            return(srvID);
        }
Ejemplo n.º 33
0
        } // TransitionCall


        // This constructor should be used for cross appdomain case.
        internal TransitionCall(IntPtr targetCtxID, IntPtr privateData, int targetDomainID)
            {
            BCLDebug.Assert(targetCtxID != IntPtr.Zero, "bad target ctx for call back");
            BCLDebug.Assert(targetDomainID != 0, "bad target ctx for call back");

            _sourceCtxID = Thread.CurrentContext.InternalContextID;
            _targetCtxID = targetCtxID;
            _delegate = null;
            _targetDomainID = targetDomainID;
            _privateData = privateData;
            

            // In the cross domain case, the client side just has a base Identity
            // and the server domain has the Server identity. We fault in the latter
            // when requested later.

                // We are going to a context in another app domain
                _srvID = null;
                _ID = new Identity("TransitionCallURI", null);

                // Create the data needed for the channel sink creation
            CrossAppDomainData data = 
                new CrossAppDomainData(_targetCtxID,
                                       _targetDomainID,
                                       Identity.ProcessGuid);
                String unUsed;
                IMessageSink channelSink =
                CrossAppDomainChannel.AppDomainChannel.CreateMessageSink(
                                                        null, //uri
                                                        data, //channelData
                                                        out unUsed);//out objURI

                BCLDebug.Assert(channelSink != null, "X-domain transition failure");
                _ID.RaceSetChannelSink(channelSink);
        } // TransitionCall
Ejemplo n.º 34
0
        IntPtr _privateData; // Used for DoCallbackInEE

        // The _delegate should really be on an agile object otherwise
        // the whole point of doing a callBack is moot. However, even if it
        // is not, remoting and serialization together will ensure that
        // everything happens as expected and there is no smuggling.

        internal TransitionCall(
            IntPtr targetCtxID, 
            CrossContextDelegate deleg)
        {
            BCLDebug.Assert(targetCtxID!=IntPtr.Zero, "bad target ctx for call back");
            _sourceCtxID = Thread.CurrentContext.InternalContextID;
            _targetCtxID = targetCtxID;
            _delegate = deleg;
            _targetDomainID = 0;
            _privateData = IntPtr.Zero;

                // We are going to another context in the same app domain
                _srvID = new ServerIdentity(
                                null, 
                                Thread.GetContextInternal(_targetCtxID));
                _ID = _srvID;
                _ID.RaceSetChannelSink(CrossContextChannel.MessageSink);
                _srvID.RaceSetServerObjectChain(this);
                
            //DBG Console.WriteLine("### TransitionCall ctor: " + Int32.Format(_sourceCtxID,"x") + ":" + Int32.Format(_targetCtxID,"x"));
        } // TransitionCall
 public static void SetObjectUriForMarshal(MarshalByRefObject obj, string uri)
 {
     Identity identity = null;
     Identity identity2 = null;
     bool flag;
     identity = MarshalByRefObject.GetIdentity(obj, out flag);
     identity2 = identity as ServerIdentity;
     if ((identity != null) && (identity2 == null))
     {
         throw new RemotingException(Environment.GetResourceString("Remoting_SetObjectUriForMarshal__ObjectNeedsToBeLocal"));
     }
     if ((identity != null) && (identity.URI != null))
     {
         throw new RemotingException(Environment.GetResourceString("Remoting_SetObjectUriForMarshal__UriExists"));
     }
     if (identity == null)
     {
         Context serverCtx = null;
         serverCtx = Thread.GetDomain().GetDefaultContext();
         ServerIdentity id = new ServerIdentity(obj, serverCtx, uri);
         if (obj.__RaceSetServerIdentity(id) != id)
         {
             throw new RemotingException(Environment.GetResourceString("Remoting_SetObjectUriForMarshal__UriExists"));
         }
     }
     else
     {
         identity.SetOrCreateURI(uri, true);
     }
 }
Ejemplo n.º 36
0
        internal static IEnvoyInfo CreateEnvoyInfo(ServerIdentity serverID)
        {
            IEnvoyInfo info = null;
            if (null != serverID)
            {
                // Set the envoy sink chain
                if (serverID.EnvoyChain == null)
                {
                    serverID.RaceSetEnvoyChain(
                        serverID.ServerContext.CreateEnvoyChain(
                            serverID.TPOrObject));
                }

                // Create an envoy info object only if necessary
                IMessageSink sink = serverID.EnvoyChain as EnvoyTerminatorSink;
                if(null == sink)
                {
                    // The chain consists of more than a terminator sink
                    // Go ahead and create an envoy info structure, otherwise
                    // a null is returned and we recreate the terminator sink
                    // on the other side, automatically.
                    info = new EnvoyInfo(serverID.EnvoyChain);
                }
            }

            return info;
        }
Ejemplo n.º 37
0
        public static void SetObjectUriForMarshal( MarshalByRefObject obj, String uri)
        { 
            // if obj is ever Marshal'd it should use this uri. If a uri has
            //   already been assigned to the object, it should throw. 
 
            Message.DebugOut("Entered SetObjectUriForMarshal \n");
 
            Identity idObj = null;
            Identity srvIdObj = null;

            bool fServer; 
            idObj = MarshalByRefObject.GetIdentity(obj, out fServer);
            srvIdObj = idObj as ServerIdentity; 
 
            // Ensure that if we have a transparent proxy then we are not given a remoting
            // proxy. This routine should only be called for objects that 
            // live in this AppDomains.
            if ((idObj != null) &&
                (srvIdObj == null)) // <-- means idObj is not a ServerIdentity
            { 
                throw new RemotingException(
                    Environment.GetResourceString( 
                        "Remoting_SetObjectUriForMarshal__ObjectNeedsToBeLocal")); 
            }
 

            if ((idObj != null) && (idObj.URI != null))
            {
                throw new RemotingException( 
                    Environment.GetResourceString(
                        "Remoting_SetObjectUriForMarshal__UriExists")); 
            } 

 
            if (idObj == null)
            {
                // obj is not ContextBound
                Contract.Assert(!(obj is ContextBoundObject), "ContextBoundObject's shouldn't get here."); 

                // Create a new server identity and add it to the 
                // table. IdentityHolder will take care of ----s 
                Context serverCtx = null;
 
                serverCtx = Thread.GetDomain().GetDefaultContext();

                Contract.Assert(null != serverCtx, "null != serverCtx");
 
                ServerIdentity serverID = new ServerIdentity(obj, serverCtx, uri);
 
                // set the identity 
                idObj = obj.__RaceSetServerIdentity(serverID);
                Contract.Assert(idObj == MarshalByRefObject.GetIdentity(obj), "Bad ID state!" ); 

                // If our serverID isn't used then someone else marshalled the object
                // before we could set the uri.
                if (idObj != serverID) 
                {
                    throw new RemotingException( 
                        Environment.GetResourceString( 
                            "Remoting_SetObjectUriForMarshal__UriExists"));
                } 
            }
            else
            {
                // This is the ContextBoundObject case 
                Contract.Assert(obj is ContextBoundObject, "Object should have been a ContextBoundObject.");
 
                idObj.SetOrCreateURI(uri, true); 
            }
 
            Message.DebugOut("Created ServerIdentity \n");
        } // SetObjectUriForMarshal
Ejemplo n.º 38
0
        // NOTE: This method is called multiple times as we reuse the
        // message object. Make sure that you reset any fields that you
        // add to the message object to the default values. This will
        // ensure that the reused message object starts with the correct
        // values.
        internal void InitFields(MessageData msgData)
        {
            _frame = msgData.pFrame;
            _delegateMD = msgData.pDelegateMD;
            _methodDesc = msgData.pMethodDesc;
            _last = -1;
            _flags = msgData.iFlags;
            _initDone = true;
            _metaSigHolder = msgData.pSig;

            _MethodName = null;
            _MethodSignature = null;
            _MethodBase = null;
            _URI = null;
            _Fault = null;
            _ID = null;
            _srvID = null;
            _callContext = null;

            if (_properties != null)
            {
                // A dictionary object already exists. This case occurs
                // when we reuse the message object. Just remove all the
                // entries from the dictionary object and reuse it.
                ((IDictionary)_properties).Clear();
            }
            
        }
Ejemplo n.º 39
0
 internal ServerIdentity __RaceSetServerIdentity(ServerIdentity id)
 {
     if (__identity == null)
     {
         // For strictly MBR types, the TP field in the identity
         // holds the real server
         if (!id.IsContextBound)
         {
             id.RaceSetTransparentProxy(this);
         }
         Interlocked.CompareExchange(ref __identity, id, null);
     }
     return (ServerIdentity)__identity;
 }
Ejemplo n.º 40
0
        internal MethodCall(Object handlerObject, BinaryMethodCallMessage smuggledMsg)
        {
            if (handlerObject != null)
            {
                uri = handlerObject as String;
                if (uri == null)
                {
                    // This must be the tranparent proxy
                    MarshalByRefObject mbr = handlerObject as MarshalByRefObject;
                    if (mbr != null)
                    {                      
						bool fServer;
                        srvID = MarshalByRefObject.GetIdentity(mbr, out fServer) as ServerIdentity; 
                        uri = srvID.URI;
                    }
                }
            }

            typeName = smuggledMsg.TypeName;
            methodName = smuggledMsg.MethodName;
            methodSignature = (Type[])smuggledMsg.MethodSignature;
            args = smuggledMsg.Args;
            callContext = smuggledMsg.LogicalCallContext;

            ResolveMethod();

            if (smuggledMsg.HasProperties)
                smuggledMsg.PopulateMessageProperties(Properties);
        }
Ejemplo n.º 41
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static ServerIdentity FindOrCreateServerIdentity(
            MarshalByRefObject obj,  String objURI, int flags) 
        {
            Message.DebugOut("Entered FindOrCreateServerIdentity \n");
                    
            ServerIdentity srvID = null;

            bool fServer;
            srvID = (ServerIdentity) MarshalByRefObject.GetIdentity(obj, out fServer);

            if (srvID == null)
            {
                // Create a new server identity and add it to the
                // table. IdentityHolder will take care of ----s
                Context serverCtx = null;
                
                if (obj is ContextBoundObject)
                {
                    serverCtx = Thread.CurrentContext;
                }
                else
                {
                    serverCtx = DefaultContext;
                }
                Contract.Assert(null != serverCtx, "null != serverCtx");

                ServerIdentity serverID = new ServerIdentity(obj, serverCtx);

                // Set the identity depending on whether we have the server or proxy
                if(fServer)
                {
                    srvID = obj.__RaceSetServerIdentity(serverID);
                    Contract.Assert(srvID == MarshalByRefObject.GetIdentity(obj), "Bad ID state!" );             
                }
                else
                {
                    RealProxy rp = null;
                    rp = RemotingServices.GetRealProxy(obj);
                    Contract.Assert(null != rp, "null != rp");

                    rp.IdentityObject = serverID;
                    srvID = (ServerIdentity) rp.IdentityObject;
                }

                Message.DebugOut("Created ServerIdentity \n");
            }

#if false
            // Check that we are asked to create the identity for the same
            // URI as the one already associated with the server object.
            // It is an error to associate two URIs with the same server 
            // object
            // GopalK: Try eliminating the test because it is also done by GetOrCreateIdentity
            if ((null != objURI) && (null != srvID.ObjURI))
            {
                if (string.Compare(objURI, srvID.ObjURI, StringComparison.OrdinalIgnoreCase) == 0) // case-insensitive compare
                {
                    Message.DebugOut("Trying to associate a URI with identity again .. throwing execption \n");
                    throw new RemotingException(
                        String.Format(
                            Environment.GetResourceString(
                                "Remoting_ResetURI"),
                            srvID.ObjURI, objURI));
                }
            }
#endif

            // NOTE: for purely x-context cases we never execute this ...
            // the server ID is not put in the ID table. 
            if ( IdOps.bStrongIdentity(flags) )
            {
                // We need to guarantee that finally is not interrupted so that the lock is released.
                // TableLock has a long path without reliability contract.  To avoid adding contract on
                // the path, we will use ReaderWriterLock directly.
                ReaderWriterLock rwlock = TableLock;
                bool takeAndRelease = !rwlock.IsWriterLockHeld;

                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    if (takeAndRelease)
                        rwlock.AcquireWriterLock(INFINITE);

                    // It is possible that we are marshaling out of this app-domain
                    // for the first time. We need to do two things
                    // (1) If there is no URI associated with the identity then go ahead 
                    // and generate one.
                    // (2) Add the identity to the URI -> Identity map if not already present
                    // (For purely x-context cases we don't need the URI)   
                    // (3) If the object ref is null, then this object hasn't been
                    // marshalled yet.
                    // (4) if id was created through SetObjectUriForMarshal, it would be
                    // in the ID table
                    if ((srvID.ObjURI == null) ||
                       (srvID.IsInIDTable() == false))
                    {
                        // we are marshalling a server object, so there should not be a
                        //   a different identity at this location.
                        SetIdentity(srvID, objURI, DuplicateIdentityOption.Unique);
                    }

                    // If the object is marked as disconnect, mark it as connected
                    if(srvID.IsDisconnected())
                            srvID.SetFullyConnected();
                }
                finally
                {
                    if (takeAndRelease && rwlock.IsWriterLockHeld)
                    {
                        rwlock.ReleaseWriterLock();
                    }
                }
            }

            Message.DebugOut("Leaving FindOrCreateServerIdentity \n");
            Contract.Assert(null != srvID,"null != srvID");
            return srvID;                
        }
Ejemplo n.º 42
0
        } // SetObjectData
 
        //
        // ResolveMethod
        //

        internal Type ResolveType()
        {        
            // resolve type
            Type t = null;

            if (srvID == null)
                srvID = IdentityHolder.CasualResolveIdentity(uri) as ServerIdentity;                

            if (srvID != null)
            {
                int startIndex = 0; // start of type name

                // check to see if type name starts with "clr:"
                if (String.CompareOrdinal(typeName, 0, "clr:", 0, 4) == 0)
                {
                    // type starts just past "clr:"
                    startIndex = 4;
                }

                // find end of full type name
                int index = typeName.IndexOf(',', startIndex);
                if (index == -1)
                    index = typeName.Length;

                Type serverType = srvID.ServerType;
                t = Type.ResolveTypeRelativeTo(typeName, startIndex, index - startIndex, serverType);
            }

            if (t == null)
            {
                // fall back to Type.GetType() in case someone isn't using
                //   our convention for the TypeName
                t = RemotingServices.InternalGetTypeFromQualifiedTypeName(typeName);
            }

            return t;
        } // ResolveType