internal static Identity ResolveIdentity(String URI)
{
if (URI == null)
throw new ArgumentNullException("URI");
Identity id;
// 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.IsReaderLockHeld;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
if (takeAndRelease)
rwlock.AcquireReaderLock(INFINITE);
Message.DebugOut("ResolveIdentity:: URI: " + URI + "\n");
Message.DebugOut("ResolveIdentity:: table.count: " + URITable.Count + "\n");
//Console.WriteLine("\n ResolveID: URI = " + URI);
// This may be called both in the client process and the server process (loopback case).
id = ResolveReference(URITable[MakeURIKey(URI)]);
}
finally
{
if (takeAndRelease && rwlock.IsReaderLockHeld){
rwlock.ReleaseReaderLock();
}
}
return id;
} // ResolveIdentity