private void EnsureInit(string configKey)
{
bool flag = false;
lock (this)
{
if (!this._isUserConfigInited)
{
if (!this._isInitInProgress)
{
this._isInitInProgress = true;
flag = true;
}
else if (!this.IsSectionUsedInInit(configKey))
{
Monitor.Wait(this);
}
}
}
if (flag)
{
try
{
try
{
string str;
this._machineConfigRecord = this._configRoot.GetConfigRecord("MACHINE");
this._machineConfigRecord.ThrowIfInitErrors();
this._isMachineConfigInited = true;
if (this._isAppConfigHttp)
{
ConfigurationManagerHelperFactory.Instance.EnsureNetConfigLoaded();
}
this._configHost.RefreshConfigPaths();
if (this._configHost.HasLocalConfig)
{
str = "MACHINE/EXE/ROAMING_USER/LOCAL_USER";
}
else if (this._configHost.HasRoamingConfig)
{
str = "MACHINE/EXE/ROAMING_USER";
}
else
{
str = "MACHINE/EXE";
}
this._completeConfigRecord = this._configRoot.GetConfigRecord(str);
this._completeConfigRecord.ThrowIfInitErrors();
this._isUserConfigInited = true;
}
catch (Exception exception)
{
this._initError = new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_client_config_init_error"), exception);
throw this._initError;
}
}
catch
{
ConfigurationManager.SetInitError(this._initError);
this._isMachineConfigInited = true;
this._isUserConfigInited = true;
throw;
}
finally
{
lock (this)
{
try
{
ConfigurationManager.CompleteConfigInit();
this._isInitInProgress = false;
}
finally
{
Monitor.PulseAll(this);
}
}
}
}
}