InvalidOperation_CalledTwice = The method cannot be called twice on the same instance.
InvalidOperation_CollectionCorrupted = A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted.
InvalidOperation_CriticalTransparentAreMutuallyExclusive = SecurityTransparent and SecurityCritical attributes cannot be applied to the assembly scope at the same time.
-InvalidOperation_SubclassedObject = Cannot set sub-classed {0} object to {1} object.
InvalidOperation_ExceptionStateCrossAppDomain = Thread.ExceptionState cannot access an ExceptionState from a different AppDomain.
InvalidOperation_DebuggerLaunchFailed = Debugger unable to launch.
InvalidOperation_ApartmentStateSwitchFailed = Failed to set the specified COM apartment state.
}
#endif // FEATURE_USE_LCID
- //
- // CheckDomainSafetyObject throw if the object is customized object which cannot be attached to
- // other object (like CultureInfo or DateTimeFormatInfo).
- //
-
- internal static void CheckDomainSafetyObject(Object obj, Object container)
- {
- if (obj.GetType().Assembly != typeof(System.Globalization.CultureInfo).Assembly) {
-
- throw new InvalidOperationException(
- String.Format(
- CultureInfo.CurrentCulture,
- Environment.GetResourceString("InvalidOperation_SubclassedObject"),
- obj.GetType(),
- container.GetType()));
- }
- Contract.EndContractBlock();
- }
-
#region Serialization
// We need to store the override from the culture data record.
private bool m_useUserOverride;
}
#endif
m_isInherited = (this.GetType() != typeof(System.Globalization.CultureInfo));
-
- // in case we have non customized CultureInfo object we shouldn't allow any customized object
- // to be attached to it for cross app domain safety.
- if (this.GetType().Assembly == typeof(System.Globalization.CultureInfo).Assembly)
- {
- if (textInfo != null)
- {
- CheckDomainSafetyObject(textInfo, this);
- }
-
- if (compareInfo != null)
- {
- CheckDomainSafetyObject(compareInfo, this);
- }
- }
}
#if FEATURE_USE_LCID
calendar = (Calendar) GregorianCalendar.GetDefaultInstance().Clone();
calendar.SetReadOnlyState(m_isReadOnly);
}
- else
- {
- CultureInfo.CheckDomainSafetyObject(calendar, this);
- }
InitializeOverridableProperties(m_cultureData, calendar.ID);
//
return;
}
- //
- // Because the culture is agile object which can be attached to a thread and then thread can travel
- // to another app domain then we prevent attaching any customized object to culture that we cannot contol.
- //
- CultureInfo.CheckDomainSafetyObject(value, this);
-
for (int i = 0; i < this.OptionalCalendars.Length; i++)
{
if (this.OptionalCalendars[i] == value.ID)