NotSupportedException:Custom calendars are not currently supported.

Feb 21 2010 5:43 PM
It is possible to create my own Calendar classes by inheriting from the Calendar class and then implementing all of the Calendar classes' abstract members. The problem is that when you attempt to assign this new Calendar to the an Exception is thrown:

CultureAndRegionInfoBuilder builder = new CultureAndRegionInfoBuilder(culrureName, CultureAndRegionModifiers.Replacement);
            CultureInfo c = new CultureInfo(culrureName);
            List<Calendar> list = new List<Calendar>();
            PersianCalendar persianCalendar = new PersianCalendar();
            list.Add(persianCalendar);
            list.AddRange(c.OptionalCalendars);
            builder.AvailableCalendars = list.ToArray();
            DateTimeFormatInfo info = builder.GregorianDateTimeFormat;
            //itPersianDateTimeFormat(info);
            builder.GetType().GetField("m_defaultCalendar", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(builder, persianCalendar);
            builder.Register();           

 the exception is:

NotSupportedException:Custom calendars are not currently supported.
i search all the internet and i can find one article that say it is because of domain safety check . anyone can help me to solve it?

Answers (2)