Groups | Blog | Home
all groups > asp.net building controls > february 2007 >

asp.net building controls : Complex Property with Subproperties Crashing VS2005 SP1


Mark Olbert
2/15/2007 7:39:14 AM
I'm in a bit of a pickle here: I've got some kind of problem involving persisting some complex properties on a custom control, but
because VS2005 SP1 keeps crashing when it encounters the problem I'm at a loss as to how to figure out what's wrong.

Here's a sketch of the custom control and properties:

[ToolboxData("<{0}:DynamicSelector runat=server></{0}:DynamicSelector>")]
[Designer(typeof(DynamicSelectorDesigner))]
[ParseChildren(false)]
[PersistChildren(false)]
[ControlBuilder(typeof(DynamicSelectorBuilder))]
public class DynamicSelector : CompositeDataBoundControl
{
private List<DynamicSelectorStep> steps = new List<DynamicSelectorStep>();

[Category("Data")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public List<DynamicSelectorStep> Steps
{
get { return steps; }
}
}

Here's the base class of the various objects I trying to persist:

public class DynamicSelectorStep
{
public event DynamicSelectorDataHandler DataBinding;
public event EventHandler Completed;

private string title;
private int selectedID = -1;
private DataBindType dataNeed = DataBindType.Unknown;

protected DynamicSelectorStep()
{
}

[NotifyParentProperty(true)]
public string Title
{
get { return title; }
set { title = value; }
}

[Browsable(false)]
public virtual string ErrorMessage
{
get { return String.Empty; }
}

[Browsable(false)]
public virtual bool IsValid
{
get { return true; }
}

[Browsable(false)]
public int Value
{
get { return selectedID; }
set { selectedID = value; }
}

[Browsable(false)]
public DataBindType DataNeed
{
get { return DataNeed; }
set { dataNeed = value; }
}

public virtual WizardStep CreateWizardStep()
{
return null;
}

public virtual void Initialize()
{
}

public virtual void DataBind( IEnumerable data )
{
}

protected virtual void OnDataBinding( DataBindType dataNeed, string arg )
{
// store what we need for the next step
this.dataNeed = dataNeed;

if( DataBinding != null ) DataBinding(this, new DynamicSelectorDataArgs(this, dataNeed, arg));
}

protected virtual void OnCompleted()
{
if( Completed != null ) Completed(this, EventArgs.Empty);
}

internal virtual string DesignTimeHtml
{
get { return String.Empty; }
}
}

The crash occurs after I open the property editor for Steps in the designer and then close it. It crashes whether or not I've tried
to add a new step.

BTW, how do I inform the property editor for Steps that there are derived classes that can be added to the collection, as well, and
that the base class can't be added?

Mark Olbert
2/15/2007 8:24:32 AM
A point of clarification: the crash occurs when I clikc on the Add button in the property editor that comes up when I try to add a
step to the step collection. Making DynamicSelectorStep publicly-constructable doesn't solve the problem.

- Mark

[quoted text, click to view]
Teemu Keiski
2/15/2007 7:34:48 PM
What is the exception you get? What does it tell? Stack overflow or
something?

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net



[quoted text, click to view]
wawang NO[at]SPAM online.microsoft.com
2/16/2007 1:53:36 AM
Hi Mark,

Would you please send me the reproducible project for further
investigation? If it proves reproducible, I will report it to product team.
Thanks.

You could also submit it to
http://connect.microsoft.com/Main/content/content.aspx?ContentID=2220 which
is monitored by our product team directly. Thank you for your effort.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Mark Olbert
2/16/2007 7:16:55 AM
Walter,

I'm sorry, but I was able to solve the problem...and don't recall which of the things I tried caused it. I think it had to do with
the settings for ParseChildren and PersistChildren.

AddThis Social Bookmark Button