diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs index 24361c55c829e..99ba0bf213b20 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs @@ -838,17 +838,22 @@ internal Type[] GetPopulatedTypes(Module module) { List typeList = new List(); - // Manual use of IDictionaryEnumerator instead of foreach to avoid DictionaryEntry box allocations. - IDictionaryEnumerator e = _typeData.GetEnumerator(); - while (e.MoveNext()) + lock (s_internalSyncObject) { - DictionaryEntry de = e.Entry; - Type type = (Type)de.Key; - ReflectedTypeData typeData = (ReflectedTypeData)de.Value; - - if (type.Module == module && typeData.IsPopulated) + Hashtable typeData = _typeData; + if (typeData != null) { - typeList.Add(type); + // Manual use of IDictionaryEnumerator instead of foreach to avoid DictionaryEntry box allocations. + IDictionaryEnumerator e = typeData.GetEnumerator(); + while (e.MoveNext()) + { + DictionaryEntry de = e.Entry; + Type type = (Type)de.Key; + if (type.Module == module && ((ReflectedTypeData)de.Value).IsPopulated) + { + typeList.Add(type); + } + } } }