locked
Strange error in MonthCalendar RRS feed

  • Question

  • Recently the strange error began to appear in my application. Application is developed a few years ago and didn't change.

    The error appears in case of a date choice in the MonthCalendar element.

    System.InvalidOperationException: Operation is not valid due to the current state of the object.   at System.Windows.Forms.MonthCalendar.WndProc(Message& m)   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam).

    .Net Framework 4, Windows 7

    Somebody faced a similar problem?
    Whether there can be the reason of this error one of updates of OS?

    Friday, May 22, 2015 12:05 PM

Answers

  • How to reproduce the error:

    https://connect.microsoft.com/VisualStudio/feedback/details/1345128/errors-after-installing-kb3023222-update

    Thursday, May 28, 2015 2:10 PM

All replies

  • Hi vshl,

    >> The error appears in case of a date choice in the MonthCalendar element.

    I made a test with MonthCalendar, but I could not reproduce your issue. Did you write your own code with MonthCalendar? I suggest you test your application in other pcs to check whether it happened in the specific pc. Could you share us a simple demo to reproduce your issue?
    I made a research about this, and here is a similar thread.

    # Strange error in MonthCalendar just started happening out of nowhere

    http://stackoverflow.com/questions/30262731/strange-error-in-monthcalendar-just-started-happening-out-of-nowhere

    Hope it will help.

    Best Regards,

    Edward

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, May 25, 2015 7:17 AM
  • I have managed to recreate the issue, hopefully this can help to reproduce for Moderator.

     public partial class Form1 : Form
      {
        public Form1()
        {
          InitializeComponent();
          monthCalendar1.DateSelected += monthCalendar1_DateSelected;
        }

        void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
        {
          textBox1.Text = e.Start.ToShortDateString();
          monthCalendar1.Dispose();
        }
      }

    I have created a simple form with just a MonthCalendar 'monthCalendar1' and a TextBox 'textBox1'. 

    This results in an InvalidOperationException: "Operation is not valid due to the current state of the object." on the call to dispose() when selecting a date.

    This issue started after installing windows update KB3023224

    After uninstall of KB3023224 the Exception is avoided.
    • Edited by Aske Brekling Tuesday, May 26, 2015 2:05 PM Updated with uninstall of windows update information
    Tuesday, May 26, 2015 11:07 AM
  • I'm having the same issued with different computers:

    those without the KB3023224 update works fine. Instead, those with that have been updated are having the same error.

    Tuesday, May 26, 2015 12:02 PM
  • Hi Aske,

    Thanks for reporting this issue about this KB update.

    >> This results in an InvalidOperationException: "Operation is not valid due to the current state of the object." on the call to dispose() when selecting a date.

    I reproduced your issue with your code, but I am a little confused about why you want to dispose the MonthCalendar in the MonthCalendar event. I made a research about KB3023224, this update resolves vulnerabilities in the Microsoft .NET Framework. These vulnerabilities could allow elevation of privilege if an attacker sends specially crafted data to a WinForms application that is running in partial trust. From my experience, it would be not a better practice to dispose the MonthCalendar when it is still be used.

    It seems that you want to dispose the MonthCalendar after you select the date, I suggest you use the Dispose method in other event like a button click event. For another method to achieve your requirement, I suggest you use dateTimePicker control which is more convenience.

    However, the current forum you posted to is used to development issue, if you still confused about why this kb made your app not work, I suggest you post this feedback to product related forum: http://answers.microsoft.com/

    Thanks for your understanding.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, May 27, 2015 9:36 AM
  • How to reproduce the error:

    https://connect.microsoft.com/VisualStudio/feedback/details/1345128/errors-after-installing-kb3023222-update

    Thursday, May 28, 2015 2:10 PM
  • Hi Daniel_R,

    Thanks for your posting.

    As the last reply from the link, Microsoft Visual Studio Connect Support Team are currently reviewing the issue, I suggest you keep following this issue in that site.

    Thanks for your understanding.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, May 29, 2015 7:21 AM