Custom ToolBoxItem type:

P

Praveen Ramesh

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.SelectDelegateObjects(System.Object[]
objects) + 0x127 bytes
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
 
S

Steven Cheng[MSFT]

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

Steven Cheng[MSFT]

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

Praveen

For the group:
If you instead derive from WebControlToolboxItem, everything works as
expected.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top