Building .Net User Controls

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...


To the property and I got an error in the designer "ObjectA is null, this is not allowed!", so I changed the line to ...


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.



It sounds like it could be the way that the object is being serialized.

The designer is doing a binary serialization of the object into the resx file, what you probably need is code to be produced in you .Designer.cs file.

Try putting the following attribute line on the property: [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

Need Your Help

resultset is closed exception on first iteration of .next()

java exception resultset cucumber-jvm

i cant figure out why my resultset is throwing the exception..

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.