Custom ToolBoxItem type:

Discussion in 'ASP .Net' started by Praveen Ramesh, Apr 14, 2005.

  1. Hi,

    I have derived from the base ToolBoxItem type as follows (it does nothing, I
    just want to get things working for now):
    [Serializable()]

    public class MyToolBoxItem : ToolboxItem

    {

    public MyToolBoxItem() : base() {}

    public MyToolBoxItem(Type toolType):base(toolType){}

    private MyToolBoxItem(SerializationInfo info, StreamingContext context)

    : base(typeof(GridGroupingControl))

    {

    Deserialize(info, context);

    }

    }

    And use the above type in my custom control as follows:

    [ToolboxItem(typeof(MyToolBoxItem ))]

    public class MyWebControl : System.Web.UI.WebControls.WebControl{...}

    But when I drag and drop this control on a page nothing happens! I see that
    the corresponding assemblies are added to the assemblies reference in the
    project, but the control itself is not getting added to the page.

    In debug mode, I see that a null reference exception occurs at the following
    call stack:

    microsoft.vsdesigner.dll!Microsoft.VSDesigner.WebForms.WebFormSelectionContainer.SelectObjects(int
    cSelect = 1, System.Object[] objects = {Length=1}, int flags = 2) + 0xcd
    bytes
    microsoft.vsdesigner.dll!Microsoft.VSDesigner.WebForms.WebFormSelectionContainer.SetSelectedObjects(System.Object[]
    objects = {Length=1}) + 0x4f bytes
    microsoft.vsdesigner.dll!Microsoft.VSDesigner.WebForms.WebFormDesigner.System.Drawing.Design.IToolboxUser.ToolPicked(System.Drawing.Design.ToolboxItem
    tool = {MyNamespace.MyToolBoxItem}) + 0x268 bytes
    microsoft.vsdesigner.dll!Microsoft.VSDesigner.WebForms.WebFormDesigner.Microsoft.VSDesigner.Interop.IWebFormDesigner.OnDragDrop(System.Object
    pDO =
    {Microsoft.VisualStudio.Designer.Service.ToolboxService.ToolboxDataObject},
    bool fNonVisualComponent = true) + 0x52 bytes

    Any ideas, anybody?

    Thanks in advance

    -Praveen
     
    Praveen Ramesh, Apr 14, 2005
    #1
    1. Advertisements

  2. Hi Praveen,

    Thanks for your posting. Regarding on this issue, I've also noticed your
    another post discussing on the similiar problem in this group. In that
    thread you're dealing with the problem of not found assembly , yes? This
    sometimes occur when the control or components has dependency assemblies
    and we can programmatcly add reference in control/component's design-time
    code through ToolboxItem.

    I'm not sure whether this is cause of the problem in this thread? From the
    code snippet you attached and the description, I'm thinking the problem
    likely concern to the ToolboxItem you applied on your control. Will the
    control be added onto page correctly if you remove the ToolboxItem for it?
    If so, we may do some further troubleshoot on the ToolboxItem's code.

    Also, if you feel convenient, would you send me a simplified version of
    your control and toolboxitem so that I can have a try on my side?

    Please feel free to post here if there is anything I can assist. Thanks,


    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Apr 15, 2005
    #2
    1. Advertisements

  3. Praveen Ramesh

    Praveen Guest

    Steven,

    Let us discus this issue in the other thread.

    Thanks
    Praveen
     
    Praveen, Apr 15, 2005
    #3
  4. Thanks for your followup.

    I'll post my response in that thread.

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Steven Cheng[MSFT], Apr 18, 2005
    #4
  5. Praveen Ramesh

    Praveen Guest

    For the group:
    If you instead derive from WebControlToolboxItem, everything works as
    expected.
     
    Praveen, Apr 21, 2005
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.