private void AcquireHierarchyLockForWrite() {
// Protect against unexpected recursive entry on this thread.
// We do this in retail, too, because the results would be very bad if this were to fail,
// and the testing for this is not easy for all scenarios.
if (_hierarchyLock.IsReaderLockHeld) {
throw ExceptionUtil.UnexpectedError("System.Configuration.Internal.InternalConfigRoot::AcquireHierarchyLockForWrite - reader lock already held by this thread");
}
if (_hierarchyLock.IsWriterLockHeld) {
throw ExceptionUtil.UnexpectedError("System.Configuration.Internal.InternalConfigRoot::AcquireHierarchyLockForWrite - writer lock already held by this thread");
}
_hierarchyLock.AcquireWriterLock(-1);
}