.NET Core Version: 3.1.2
Have you experienced this same bug with .NET Framework?: No
Problem description:
Set MinDate (monthCalendar1.MinDate = DateTime.Today;) , then select some date in calendar -
NullReferenceException occur:
NullReferenceException
at System.Windows.Forms.MonthCalendar.MonthCalendarAccessibleObject.GetCalendarCell(Int32 calendarIndex, AccessibleObject parentAccessibleObject, Int32 columnIndex)
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.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 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.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 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.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WinFormsCoreTest1.Program.Main() in d:\save\projects\core tests\WinFormsCoreTest3\Program.cs:line 24

Expected behavior:
No exception.
Windows 7 x64.
Minimal repro:
WinFormsCoreTest4.zip
P.s.
We had grate plans about migration our apps to core. A lot of work were done in research, converting old project to new sdk format and then adopting to core... And after brief view on the result (not even testing!!!) I have found 4 problems that make core variant of WinForms unusable :( At least, until version 5.0 I think: ((((
@merriemcgaw we'll have to patch this.
And after brief view on the result (not even testing!!!) I have found 4 problems that make core variant of WinForms unusable
That's not good. Please raise these problems here as separate issues, and we'll have a look at them.
3.1 is a LTS release, so we'll consider patching blocking broken behaviour.
@RussKie Already done, 3 other issues:
https://github.com/dotnet/winforms/issues/3022
https://github.com/dotnet/winforms/issues/3032
https://github.com/dotnet/winforms/issues/3033
Could you please add the stack trace to the top post?
Could you please add the stack trace to the top post?
Done, under NullReferenceException tag in 1 post.
@RussKie This is a duplicate issue to https://github.com/dotnet/winforms/issues/2475, @vladimir-krestov is working on it.
@RussKie This is a duplicate issue to #2475, @vladimir-krestov is working on it.
Oh, sorry - my bad :-(
@vladimir-krestov the issue in #2475 cannot reproduce in the latest .NET Core 5.0 SDK, but this current issue still can reproduce in latest .NET Core 5.0 SDK, please confirm if they are the same issue.
@John-Qiao,
They are the same issues. Please look at the comment - "This happens if the MinDate and MaxDate are set."
I couldn't reproduce NRE in a case if a min/max date isn't set.
Maybe you checked this case?
@vladimir-krestov yes, you're right, it occurs when a min/max date is set.
Fixed in 3.1.4.

Thank you for the follow up!
Most helpful comment
@RussKie This is a duplicate issue to https://github.com/dotnet/winforms/issues/2475, @vladimir-krestov is working on it.