I have published a Visual Studio 2010 extension called Duplicate Selection which is primarily invoked via the hotkey. However it also has a menu item under the Edit menu. This all works fine, but I would like to change the icon for the menu item. The icon for the menu item is supposed to be defined in the .vsct file:
<Commands package="guidDupSelectionPkg">
<Groups>
<Group guid="guidDupSelectionCmdSet" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_EDIT"/>
</Group>
</Groups>
<Buttons>
<Button guid="guidDupSelectionCmdSet" id="cmdidDupSelection" priority="0x0100" type="Button">
<Parent guid="guidDupSelectionCmdSet" id="MyMenuGroup" />
<Icon guid="guidCmdIcon" id="bmpCmdIcon" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DontCache</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
<CommandName>cmdidDupSelection</CommandName>
<ButtonText>Duplicate Selection</ButtonText>
</Strings>
</Button>
</Buttons>
<Bitmaps>
<!--<Bitmap guid="guidImages" href="Resources\Images_32bit.bmp" usedList="bmpPic1, bmpPic2, bmpPic开发者_高级运维Search, bmpPicX, bmpPicArrows"/>-->
<Bitmap guid="guidCmdIcon" href="Resources\cmdicon.bmp" usedList="bmpCmdIcon" />
</Bitmaps>
</Commands>
<KeyBindings>
<KeyBinding guid="guidDupSelectionCmdSet" id="cmdidDupSelection" key1="D" mod1="Alt" editor="guidVSStd97"/>
</KeyBindings>
<Symbols>
<GuidSymbol name="guidDupSelectionPkg" value="{e5f7e157-f686-46b7-a588-85b08cdaa5f0}" />
<GuidSymbol name="guidDupSelectionCmdSet" value="{85dcd5f2-19a5-4ee2-a99b-4fac4dc5c4ca}">
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="cmdidDupSelection" value="0x0100" />
</GuidSymbol>
<!--<GuidSymbol name="guidImages" value="{63df12b7-6bf0-4b19-843d-3ec69e08439d}">
<IDSymbol name="bmpPic1" value="1" />
<IDSymbol name="bmpPic2" value="2" />
<IDSymbol name="bmpPicSearch" value="3" />
<IDSymbol name="bmpPicX" value="4" />
<IDSymbol name="bmpPicArrows" value="5" />
</GuidSymbol>-->
<GuidSymbol name="guidCmdIcon" value="{e4cc0e42-a09d-4602-a965-d2b3f7e1f496}">
<IDSymbol name="bmpCmdIcon" value="1" />
</GuidSymbol>
</Symbols>
You can see I have commented out the old definitions that I no longer want to use, and added my own. Near the top, I have <Icon guid="guidCmdIcon" id="bmpCmdIcon" />
, which should reference my new bitmap. When I run the project under the debugger, the VS experimental instance is still using the old icon! Is this a bug in VS?? That icon isn't even defined in my vsct file any more. How could it still be using it? Have I done something wrong here?
Any suggestions or speculation would be apprciated. I've tried several different things, but I'm officially stumped on this one.
Visual Studio builds a private cache for menu data so that it doesn't have to load DLL's that provide resources unnecessarily. Delete this (hidden) file and try debugging again:
%LocalAppData%\Microsoft\VisualStudio\10.0Exp\1033\devenv.CTM
This article describes the menu merging process in more detail in case you're curious.
精彩评论