Jonathan Brown

I am using VS2005 Beta 2

If I create a UserControl using the Windows Control Library template and then attempt to use it in a hosting window (i.e. a normal windows forms app) I get an error when the control is dropped onto the host form from the toolbox:-

Failed to create component 'usercontrolname'
Xml Exception, An error occurred while parsing EntityName, Line 2, position 51


If I declare and instantiate the control directly in the host form's code (VB) it works fine. For some reason the form designer will not display the user control when placed onto a host form. The control itself can be designed as normal. The control project can be run and the test harness works fine. 

The UserControl in question is very simple - it just contains a standard label control.




Re: Windows Forms Designer Problem with UserControl and form designer

MrFile

Funny i am having the same problem in VS 2005, SP1. I created a custom control, added a label to it, tried to drag the label onto the form and BAM i get the XML exceptino on sime line, at some position.



Re: Windows Forms Designer Problem with UserControl and form designer

xr280xr

It is probably the designer generated code setting one of your properties to an invalid value. You should make sure your properties validate the values they are receiving (e.g. check against null values etc.). You can also hide your properties from the designer to ensure it doesn't try to initialize them with the following attribute:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

Check your designer code (YourForm.Designer.cs) for clues as to what properties might be blowing up. Hope that helps.