I am currently building a .Net userform using C# and I am populating it with custom user controls. The controls each have an accessor that gets and sets the object that contains the data that the control will be populated with.
At runtime, everything works great, but at design time I will get errors in the form designer. The errors are always along the lines of "Cannot convert an object of type [ObjectA] to an object of type [ObjectA]"
At this point, I can go into the resx file and delete the row that references the object of type ObjectA and then go into the designer.cs file and delete the line in InitializeComponent that sets the accessor of the control to the data from the resx file.
Once I've done that, the form will display in the designer until it rebuilds the InitializeComponet and reinserts the lines / data into the resx and InitializeComponent.
What am I missing in my control and class design that will end this cycle? I've tried using the Liscence Usage mode and the Designer runtime mode with mixed results and I would prefer it if I could solve this in my design.
Thanks for any help that you can provide.
Update: I added the attribute...
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
To the property and I got an error in the designer "ObjectA is null, this is not allowed!", so I changed the line to ...
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
and the issue went away. Since I don't need to set any of these properties at design time, the hidden attribute is probably more appropriate.
Thanks.