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.

NullReferenceException in monthCalendar after setting MinDate

See original GitHub issue
  • .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

mc

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: ((((

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
Vino-Wangcommented, Apr 3, 2020

@RussKie This is a duplicate issue to https://github.com/dotnet/winforms/issues/2475, @vladimir-krestov is working on it.

1reaction
RussKiecommented, May 20, 2020

Thank you for the follow up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

MonthCalendar.MinDate Property (System.Windows.Forms)
The following code example displays a form containing a MonthCalendar control that displays one calendar year. The example demonstrates setting the ...
Read more >
Possible to set monthCalendar to show current month and ...
You can use the following line of code to set the MonthCalendar 's MaxDate property to current date in the form's load event....
Read more >
NullReferenceException when changing the selected date
NullReferenceException when changing the selected date ... Hi. I use RadCalendar in my project for selection date. ... Usually it works correctly.
Read more >
DatePicker
The MaxDate and MinDate properties determine the range of dates that a user can enter or pick in the control. If you set...
Read more >
VB Using Month Calendar Control and Date Time ... - YouTube
We can limit the Minimum and Maximum Date which can be chosen. ... to 21:14 When to use Date Time Picker 21:14 to...
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