I’m currently using Microsoft Visual C# Express Edition (with SP1) for a Project. I’m getting some strange errors in the Forms editor when editing one particular form, the message reads:
Type ‘System.Windows.Forms.Control’ in assembly ‘System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ is not marked as serializable.
and it apperars on trying to save the form. It mostly appears 3 to 5 times consecutively but sometimes also pops up every few seconds nonstop, until I kill the application.
I believe it starts when I tried to add some Application-Settings, but I can’t seem to reproduce it.
Any ideas how to spot the error would be appreciated, thank you.
Edit: Saving the form means clicking the ‘Save’ Button in Visual C# Express. I am not trying to serialize it manually, the error pops up while editing the form in the IDE.
Edit: Here is a screenshot – This pops up when I save the form.
http://img10.imageshack.us/my.php?image=notserializable.png
The Windows Forms designer serializes your form as you edit it, inside the
.Designer.cs. That’s why you often see the error as your edit your form.Usually, you edit classes deriving from
UserControlorFormin the designer. Your error seems to indicate it’s trying to serialize a Control. Did you change the base class of MainForm to Control?Or did you edit the MainForm.Designer.cs file manually? I strongly recommend not editing the .Designer.cs file directly because if you do, it’s really easy to break the Windows Forms Designer support.