locked
Toolbox items duplicated because previous cache loading RRS feed

  • Question

  • Hi ,

    I am developing VS extension package that has few custom editors and each editor has it's own set of toolbox items.

    I referenced "Visual Studio 2010 SDK Samples" and tried to figure out what is the "Right" way and time to add the ToolboxItems,I noticed that according to "Editor in a Toolwindow" sample the ToolboxItem is created in the Initialize method in my EditorPane,

    this scenario causes my toolbox items to duplicate since the toolboxitems are being loaded automatically from the cache and each time i open my EdidorPane for the first time the same toolbox item are being added to the VS ToolBox  (with IVsToolbox).

    Please advice.

    Thanks

    P.s.

    I allready referenced this post http://social.msdn.microsoft.com/Forums/en/vsx/thread/aeac6b1e-b7cc-4e0b-a8a0-ca7ae8b6a89a and I don't seem to help.


    • Edited by MickeyAlk Tuesday, May 8, 2012 8:56 AM
    Tuesday, May 8, 2012 8:53 AM

Answers

  • You should not be creating new toolbox items when your editor is loaded.  Instead, your package should register as a default content provider (using ProvideToolboxItemsAttribute) and subscribe to the ToolboxInitialized and/or ToolboxUpgraded events from the Package base class.  Add your items in the event handler.

    -Josh Stevens

    VS Shell team

    Monday, May 14, 2012 9:59 PM

All replies

  • Hi MickeyAlk,

    Thank you for your question.

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Thank you for your understanding and support.


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, May 11, 2012 6:57 AM
  • I deal with this by putting all my items into a new group in the toolbox (not general).  Then, when the editor is loaded, I remove all the entries in the group and reinsert them.  Works ok as long as you don't have too many entries.
    Friday, May 11, 2012 10:28 PM
  • You should not be creating new toolbox items when your editor is loaded.  Instead, your package should register as a default content provider (using ProvideToolboxItemsAttribute) and subscribe to the ToolboxInitialized and/or ToolboxUpgraded events from the Package base class.  Add your items in the event handler.

    -Josh Stevens

    VS Shell team

    Monday, May 14, 2012 9:59 PM