question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

  1. This issue cannot reproduce on DateTimePicker.
  2. This issue cannot reproduce on .Net 3.1.

Minimal repro:

  1. Create a Winforms Core application.
  2. Drag and drop a MonthCalendar to the form designer.
  3. 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. image

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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Jessie-Zhang01commented, Apr 1, 2020

Verified the issue with .Net core 5.0 Preview 3.1.300.015048, the issue is fixed.

0reactions
vladimir-krestovcommented, Mar 10, 2020

This is incorrect getting SYSTEMTIME from MCGRIDINFO structure when sending a system message to Windows. (DateTimePicker.SysTimeToDateTime() method) PR #2911 fixes this issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found