atifaziz / NCrontab

Crontab for .NET
Apache License 2.0
905 stars 137 forks source link

NCrontabViewer throwing InvalidCastException #87

Closed jdmallen closed 3 years ago

jdmallen commented 3 years ago

This line and this line each fail to be casted to ISupportInitialize. Looks like ToolStripStatusLabel no longer inherits from that interface in .NET 5.0. Commenting out both the lines allows the program to run just fine.

System.InvalidCastException
  HResult=0x80004002
  Message=Unable to cast object of type 'System.Windows.Forms.ToolStripStatusLabel' to type 'System.ComponentModel.ISupportInitialize'.
  Source=System.Private.CoreLib
  StackTrace:
   at System.Runtime.CompilerServices.CastHelpers.ChkCast_Helper(Void* toTypeHnd, Object obj)
   at System.Runtime.CompilerServices.CastHelpers.ChkCastInterface(Void* toTypeHnd, Object obj)
   at NCrontabViewer.MainForm.InitializeComponent() in D:\git\NCrontab\NCrontabViewer\MainForm.Designer.cs:line 44
   at NCrontabViewer.MainForm..ctor() in D:\git\NCrontab\NCrontabViewer\MainForm.cs:line 46
   at NCrontabViewer.Program.Main() in D:\git\NCrontab\NCrontabViewer\Program.cs:line 37
System.InvalidCastException
  HResult=0x80004002
  Message=Unable to cast object of type 'System.Windows.Forms.ToolStripStatusLabel' to type 'System.ComponentModel.ISupportInitialize'.
  Source=System.Private.CoreLib
  StackTrace:
   at System.Runtime.CompilerServices.CastHelpers.ChkCast_Helper(Void* toTypeHnd, Object obj)
   at System.Runtime.CompilerServices.CastHelpers.ChkCastInterface(Void* toTypeHnd, Object obj)
   at NCrontabViewer.MainForm.InitializeComponent() in D:\git\NCrontab\NCrontabViewer\MainForm.Designer.cs:line 176
   at NCrontabViewer.MainForm..ctor() in D:\git\NCrontab\NCrontabViewer\MainForm.cs:line 46
   at NCrontabViewer.Program.Main() in D:\git\NCrontab\NCrontabViewer\Program.cs:line 37
atifaziz commented 3 years ago

Thanks for reporting this! Feel free to send a PR if you wish to receive credit otherwise I'll close this issue when I get round to fixing it.

jdmallen commented 3 years ago

I'm not sure the best approach to fixing it, as I'm not terribly familiar with what ISupportInitialize does. I do know that it seems to work fine with the line omitted; I see a status bar with "Ready" at the bottom of the window. If that's the best solution, I'll happily remove the two offending lines in a PR.

jdmallen commented 3 years ago

I put a PR in anyway for you to merge at your discretion. Thanks!