Q:

Strange error in MonthCalendar just started happening out of nowhere

This crash report started coming through 2 days ago from a lot of our users. There have been no updates to our code, and this error is happening on multiple versions. Some of these versions are years old so it's not like an update broke something. It's a .NET 4.0 app using Infragistics 2014 Vol 2. Infragistics support seem to think it's a bug in the MonthCalendar for Windows Forms but I haven't been able to find anything online. From the screenshot with the crash dump it looks like all the users are doing is clicking to dropdown the calendar, when they get this error. I haven't been able to replicate it.
System.InvalidOperationException: Operation is not valid due to the current state of the object.
at System.Windows.Forms.MonthCalendar.WndProc(Message& m)
at Infragistics.Win.MonthDropDownWithUIPermissions.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Does anyone have any ideas what could be causing this? It's critical, and I have nowhere to even start.

A:

Thanks for Mangist response. It help me find the cause of the problem. I was having problems with the MonthCalendar control, the source of the problem was control's internal methods for displaying bolded dates. I was filling the BoldedDates property with an array of Dates. That was causing the control to automatically call the UpdateBoldedDates() function and there was the crash.
All I did was that I replaced the code by adding bolded date one by one (there is no performance loss). When doing this, the UpdateBoldedDates() function must be called manually ( which saved my life :) ).
So, after filling up the MonthCalendar with bolded dates I used the "workaround" and called the UpdateBoldedDates() function in the worker thread. Here is my code (in Visual Basic.NET):
Private Sub UpdateBoldedDatesWT()
    mcCalendar.UpdateBoldedDates()
End Sub

Public Sub LoadBoldedDates()

    Dim bDates As List(Of Date)

    Try
        Dim dExt As New DatesHelper(sqlConn)
        bDates = dExt.GetAppointmentDates(mcCalendar.SelectionStart)
        mcCalendar.RemoveAllBoldedDates()

        For Each d As Date In bDates
            mcCalendar.AddBoldedDate(d)
        Next

        mcCalendar.BeginInvoke(New MethodInvoker(AddressOf UpdateBoldedDatesWT))
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, "Error loading bolded dates")
    End Try

End Sub

A:

Here is a Microsoft Hotfix rollup 3064711 for the Crash:
https://support.microsoft.com/en-us/kb/3064711
Problems solved:
Assume that you are running a Windows Forms application. When the application disposes a System.Windows.Forms.MonthCalendar control in certain cases, the following InvalidOperationException exception will be thrown:
Operation is not valid due to the current state of the object.
MS Connect Thread:
https://connect.microsoft.com/VisualStudio/feedback/details/1345128/errors-after-installing-kb3023222-update

