locked
VSPackage: add a context menu item where another extension may be conflicting RRS feed

  • Question

  • I have installed the Oracle Developer Tools for Visual Studio and I am attempting to create a VSPackage extension for packaging Oracle scripts for release. I would like the extension to work by allowing the user to right click on the deployment script in the Solution Explorer in the Oracle DB project and be presented with a context menu option to bundle the scripts.

    I have created the VSPackage project and defined the menu entry. I set it's parent to IDM_VS_CTXT_ITEMNODE. If I run the Visual Studio Experimental Instance, load a solution and right click on any items in the Oracle Db projects the menu item is missing.

    Additionally I tried adding a non-sql item (*.cs file) to the Oracle Db project. When I right click on that item in the Oracle Db project, my menu item is not present.

    If I right click on any items (a *.cs file, for example) in other project types in the same solution, I see my menu item.

    Using PowerShell I queried the IDE for its list of CommandBars and I think I found the Instance ID for the project item (DBProjScriptCtx - 0x0613), but because this is not defined in vsshlids.h I cannot reference it... or at least I cannot figure out how to reference it. So my question: is there a way to get my menu item into the context menu that seems to be owned by the Oracle Developer Tools for VS add-in?

    I am working in VS 2013(12.0.31101.00 Update 4) with VS 2013 SDK.

    The test solution environment - installed ODAC 12c Release 2 and Oracle Developer Tools for Visual Studio (12.1.0.1.2) and created a solution with one Oracle Db Project and one non-Oracle Db project. Used the Visual Studio Package project template to create the VSPackage.

    I am very new with VSX so if I am overlooking something obvious, please excuse my ignorance. Thanks in advance for any assistance.

    Friday, December 19, 2014 2:02 PM

Answers

  • Hi Sven,

    If the project type containing the files was written by Oracle, they may have chosen to implement their own context menu, instead of reusing the default.

    To verify this, you can use the EnableVSIPLogging registry value, to retrieve the guid:id pair of the context menu as described here. (note, you'll need to fix up the version # in the  registry key to correlate with VS 2013.

    If you parent your menu group to the context menu identified by that guid:id pair, I suspect you'll find your menu items added as expected.

    Sincerely,


    Ed Dore

    • Marked as answer by Sven Hoek Saturday, December 20, 2014 12:39 PM
    Friday, December 19, 2014 5:53 PM

All replies

  • Hi Sven,

    If the project type containing the files was written by Oracle, they may have chosen to implement their own context menu, instead of reusing the default.

    To verify this, you can use the EnableVSIPLogging registry value, to retrieve the guid:id pair of the context menu as described here. (note, you'll need to fix up the version # in the  registry key to correlate with VS 2013.

    If you parent your menu group to the context menu identified by that guid:id pair, I suspect you'll find your menu items added as expected.

    Sincerely,


    Ed Dore

    • Marked as answer by Sven Hoek Saturday, December 20, 2014 12:39 PM
    Friday, December 19, 2014 5:53 PM
  • Ed,

    Thank you for responding. I have made the edit to use the VSIPLogging and was able get the information regarding the GUID:ID:

    As I am a newb with VSX I am not sure what/where to make my edits to change the .vsct file to re-parent my menu group with the information gleaned above.

    I tried defining a new GuidSymbol element using the Guid above but I am not sure which ID (GUIDId or CmdID - I'm guessing GuidId) and how to pair that with the Guid.

    I added the content below to my .vsct file and set the parent of my menu group to this GUID:ID pair but I am not seeing my menu group/items in the context menu.

        <GuidSymbol name="guidODT_Pkg" value="{C25F9CFD-6AF5-452D-99B0-17313C07CAC0}">
          <IDSymbol name="ODT_CTX_MENU" value="0x0430"/>
        </GuidSymbol>

        <Groups>
          <Group guid="guid_ODT_DeploymentsCmdSet" id="MyMenuGroup" priority="0x0600">
            <Parent guid="guidODT_Pkg" id="ODT_CTX_MENU"/>
          </Group>
        </Groups>

    What am I doing wrong?

    Friday, December 19, 2014 10:51 PM
  • I think you need to use the Guid and CmdID values. I think that guidID is just something used internally by the shell.

    Ed Dore

    Saturday, December 20, 2014 5:12 AM
  • Thanks for setting me on the right path.

    I tried the CmdId as well before my last response but it didn't seem to work. What I neglected to determine was if the values being presented in the VSDebug Message were decimal or hex. Since the hex value for IDM_VS_CTXT_ITEMNODE is known (0x0430), I tested by getting the value displayed by the dialog when right-clicking on a non-Oracle Db project item. The value displayed on the VSDebug Message is decimal.

    Once I changed vsct file IDSymbol value attribute to the CmdId of the Oracle DBProjScriptCtx and used the hex value (Dec 4197 = Hex 1065), my menu item appeared in the correct context menu.

        <GuidSymbol name="guidODT_Pkg" value="{C25F9CFD-6AF5-452D-99B0-17313C07CAC0}">
          <IDSymbol name="ODT_CTX_MENU" value="0x1065"/>
        </GuidSymbol>


    So the solution for this issue is:

    • Use the EnableVSIPLogging registry value to retrieve the guid:id pair of the context menu to which you want to add your menu item as described here (note, you'll need to fix up the version # in the registry key to correlate with VS version you are using).
    • With the Guid and CmdId in hand, create a new GuidSymbol with the Guid and IDSymbol using the CmdId.
       <GuidSymbol name="guidODT_Pkg" value="{C25F9CFD-6AF5-452D-99B0-17313C07CAC0}">
          <IDSymbol name="ODT_CTX_MENU" value="0x1065"/>
       </GuidSymbol>
    • Set the Parent element of your menu group to the guid and id you created in the previous step.
        <Groups>
          <Group guid="guid_ODT_DeploymentsCmdSet" id="MyMenuGroup" priority="0x0600">
            <Parent guid="guidODT_Pkg" id="ODT_CTX_MENU"/>
          </Group>
        </Groups>

    Ed - thanks so much for your help!





    • Edited by Sven Hoek Saturday, December 20, 2014 12:25 PM
    Saturday, December 20, 2014 11:33 AM
  • Hi ED Dore,


    I have created my own project type in VS2019 and VS2017 using project templates and Item template.

    However when I add file to the project and right click on the file I don't see context menu with my menu items which I see in VS2017.

    For VS2019 i see following GUID and command ID. I have seen this by enabling VSIP logging .

    GUID : d309f791-903f-11d0-9efc-00a0c911004f
    cmd id : 1037

    Could you please let me know what changes i need to make in VS2019 so that i can see context menu as per VS2017.?

    Thanks & Regards,

    Ajay

    Wednesday, April 10, 2019 1:37 PM