internal void SetOrCreateURI(String uri, bool bIdCtor) { if (bIdCtor == false) { // This method is called either from the ID Constructor or // with a writeLock on the ID Table BCLDebug.Assert(IdentityHolder.IsWriterLockHeld(), "IDTable should be write-locked"); if (null != _ObjURI) { throw new RemotingException( Environment.GetResourceString("Remoting_SetObjectUriForMarshal__UriExists")); } } if (null == uri) { // We insert the tick count, so that the uri is not 100% predictable. // (i.e. perhaps we should consider using a random number as well) _ObjURI = IDGuidString + Environment.TickCount + "_" + GetNextSeqNum() + ".rem"; } else { if (this is ServerIdentity) { _ObjURI = IDGuidString + uri; } else { _ObjURI = uri; } } } // SetOrCreateURI
internal void ResetInIDTable(bool bResetURI) { BCLDebug.Assert(IdentityHolder.IsWriterLockHeld(), "IDTable should be write-locked"); while (true) { int currentFlags = _flags; int newFlags = _flags & (~IDFLG_IN_IDTABLE); if (currentFlags == Interlocked.CompareExchange(ref _flags, newFlags, currentFlags)) { break; } } // bResetURI is true for the external API call to Disconnect, it is // false otherwise. Thus when a user Disconnects an object // its URI will get reset but if lifetime service times it out // it will not clear out the URIs if (bResetURI) { ((ObjRef)_objRef).URI = null; _ObjURI = null; } }