Skip to content

An exception occurred when MonthCalendar switched dates #2912

@Jessie-Zhang01

Description

@Jessie-Zhang01
  • .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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions