An exception occurred when MonthCalendar switched dates
See original GitHub issue-
.NET Core Version: 5.0.100-preview.1.20125.9
-
Have you experienced this same bug with .NET Framework?: No
More Info
- This issue cannot reproduce on DateTimePicker.
- This issue cannot reproduce on .Net 3.1.
Minimal repro:
- Create a Winforms Core application.
- Drag and drop a MonthCalendar to the form designer.
- Build and run this application, then double click other date.
Expected behavior: The date is switched successfully.
Actual behavior:
An exception occurred when MonthCalendar switched dates.

System.ArgumentOutOfRangeException
HResult=0x80131502
Message=Year, Month, and Day parameters describe an un-representable DateTime.
Source=System.Private.CoreLib
StackTrace:
at System.ThrowHelper.ThrowArgumentOutOfRange_BadYearMonthDay()
at System.DateTime..ctor(Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second)
at System.Windows.Forms.MonthCalendar.MonthCalendarAccessibleObject.GetCalendarRow(Int32 calendarIndex, AccessibleObject parentAccessibleObject, Int32 rowIndex)
at System.Windows.Forms.MonthCalendar.MonthCalendarAccessibleObject.GetCalendarChildAccessibleObject(Int32 calendarIndex, CalendarChildType calendarChildType, AccessibleObject parentAccessibleObject, Int32 index)
at System.Windows.Forms.MonthCalendar.MonthCalendarAccessibleObject.GetCalendarChildAccessibleObject(DateTime selectionStart, DateTime selectionEnd)
at System.Windows.Forms.MonthCalendar.WmDateChanged(Message& m)
at System.Windows.Forms.MonthCalendar.WmReflectCommand(Message& m)
at System.Windows.Forms.MonthCalendar.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
at Interop.User32.SendMessageW(IHandle hWnd, WM Msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.ReflectMessage(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmNotify(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
at Interop.User32.CallWindowProcW(IntPtr wndProc, IntPtr hWnd, WM msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
at Interop.User32.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(UIntPtr dwComponentID, msoloop uReason, Void* pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApp2.Program.Main() in C:\Users\v-ruizha\source\repos\WindowsFormsApp2\WindowsFormsApp2\Program.cs:line 20
This exception was originally thrown at this call stack:
[External Code]
WindowsFormsApp2.Program.Main() in Program.cs
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Problem with DateChanged event on MonthCalendar
The DateChanged event occurs during any date selection, whether by mouse, keyboard, or code. So the DateChanged event will occur when you click ......
Read more >MonthCalendar.DateChanged Event (System.Windows. ...
The DateChanged event occurs during any date selection, whether by mouse, keyboard, or code. The DateSelected event is similar, but it occurs only...
Read more >Calendar month view error - solspace
I am on a Pro license and only plugins I have installed are: Contact Form (P&T); Focus Point; Instagram Feed (currently disabled); Minimee ......
Read more >Another Month Calendar
A customizable month calendar with support for date formatting. ... visible is the month region, all the others can be switched on or...
Read more >Month calendar view apple watch 7
Month calendar view apple watch 7. Hello,. using the standard calendar app I am unable to view the full month on the calendar...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Verified the issue with .Net core 5.0 Preview 3.1.300.015048, the issue is fixed.
This is incorrect getting SYSTEMTIME from MCGRIDINFO structure when sending a system message to Windows. (
DateTimePicker.SysTimeToDateTime()method) PR #2911 fixes this issue.