Why falling InvalidCastException?

Need to go over the TableLayoutPanel.ColumnStyles.
Use a regular foreach:

foreach (ColumnStyle style in myTableLayout.ColumnStyles)
 // produce their actions

Falls System.InvalidCastException on the line ColumnStyle style in myTableLayout.ColumnStyles:
Could not allow the object type "System.Windows.Forms.RowStyle" to type "System.Windows.Forms.ColumnStyle".


Access MSDN looking.

Rebuild and Clean - does not help.
July 9th 19 at 10:34
2 answers
July 9th 19 at 10:36
Don't know what it was, but after deleting the project directory
and re-clone from VCS problem disappeared.
Thank you all!
July 9th 19 at 10:38
You have the wrong type conversion
you are trying to System.Windows.Forms.RowStyle allow the type System.Windows.Forms.ColumnStyle
more the error does not say
MyClass != MySourceClass

Find more questions by tags C#Windows Forms