locked
How to auto load a package in c++ RRS feed

  • Question

  • Dear All,

    I have been trying to auto load my package in visual studio. All the examples ..I see are always related with C#. I tried whatever I could to the best of my knowledge.... but failed. 

    Please suggest me the steps. I am lost. C++ is an orphaned child of microsoft ...it seems... so much for managed code.


    • Edited by Caillen Thursday, September 4, 2014 7:13 AM Dirty words.
    Wednesday, September 3, 2014 1:19 PM

Answers

  • finally found how to deploy. simply double click VSIX file generated by the visual studio. 

    EnvDTE.executeCommand( "Tools.MyCommand","") loaded the package. I have achieved by adding a dummy addin which simply triggers the loading of package. 

    If there are any smart ways of doing it...please post in here. 

    • Marked as answer by klkvgupta Friday, September 5, 2014 6:44 PM
    Friday, September 5, 2014 6:44 PM

All replies

  • Hi,

    Please check these documents firstly:

    How to: Autoload a VSPackage

    ProvideAutoLoadAttribute Class

    To automatically load the package into the VS, you need to apply ProvideAutoLoadAttribute to your VSPackage class that inherits from Package or implements IVsPackage to cause your class to be automatically loaded when a specified UI context is active.This attribute makes your VSPackage an extender (an object which implements IExtenderProvider). The GUID passed to the constructor determines the context in which the package loads. In C#, you don't need the suffix "Attribute". This is actually almost the same whether in C# or in VB.NET/C++ VSPackage projects.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 4, 2014 7:37 AM
  • Visual Studio 2010 or higher autoloads packages that are registered in the Windows Registry for a given UI context:

    HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\AutoLoadPackages\<UI_CONTEXT_GUID>

    The 12.0 part is for VS 2013. The "_Config" part is generated by Visual Studio in the HKEY_CURRENT_USER hive merging:

    • HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\12.0
    • .pkgdef files in known folders on disk

    Do not ever touch HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config:

    • When using managed languages (MPF), the ProvideAutoload attribute causes that the utility that generates the .pkgdef file adds:

    ...
    [$RootKey$\Packages\{<my_package_guid>}]
    @="MyVSPackagePackage"
    "InprocServer32"="$WinDir$\SYSTEM32\MSCOREE.DLL"
    "Class"="MyCompany.MyVSPackage.MyVSPackagePackage"
    "CodeBase"="$PackageFolder$\MyVSPackage.dll"
    [$RootKey$\AutoLoadPackages\{adfc4e65-0397-11d1-9f4e-00a0c911004f}]
    "{<my_package_guid>}"=dword:00000000
    ...

    where {ADFC4E65-0397-11D1-9F4E-00A0C911004F} is the context for EmptySolution (just an example).

    And the .pkgdef in turn will be merged in the registry entry HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config.

    • When using unmanaged languages (C++) I guess you have to edit manually the .pkgdef file of your project. If for some reason you are not using the .pkgdef mechanism for registration, your setup must add that registry entry in the HKEY_LOCAL_MACHINE hive.


    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    • Proposed as answer by Carlos J. Quintero Friday, September 5, 2014 12:31 PM
    • Unproposed as answer by klkvgupta Friday, September 5, 2014 4:54 PM
    Friday, September 5, 2014 12:31 PM
  • Thanks for your response.

    I am already using pkgdef utility and already tried your proposed solution and didn't  work. What I am trying now is to write a add-in which triggers my package. 

    Now I am stuck at the point on "how to deploy my package". I can start experimental instance of my package but add-in is not there to test it. So...I am trying to deploy my package so that I can test both add-in and package together.

    If you know how to deploy a c++ package, please let me know. Now I am struggling in the next phase.  Please help.


    Friday, September 5, 2014 4:54 PM
  • Hi,

    An add-in is not the solution, mainly because next version VS "14" will remove add-ins.

    Can you post the contents of your .pkgdef file?


    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    Friday, September 5, 2014 5:55 PM
  • finally found how to deploy. simply double click VSIX file generated by the visual studio. 

    EnvDTE.executeCommand( "Tools.MyCommand","") loaded the package. I have achieved by adding a dummy addin which simply triggers the loading of package. 

    If there are any smart ways of doing it...please post in here. 

    • Marked as answer by klkvgupta Friday, September 5, 2014 6:44 PM
    Friday, September 5, 2014 6:44 PM
  • It would be nice if you could show me my errors with Pkgdef. Here is my file.

    [$RootKey$\Packages\{7de5e018-ebb8-4478-ba36-bfc716f5a0f8}]
    @="FileSync Package"
    "InprocServer32"="$PackageFolder$\FileSync.dll"
    "CodeBase"="$PackageFolder$\FileSync.dll"
    "Class"="Rohde & Schwarz.FileSync.FileSyncPackage"
    "CompanyName"="Rohde & Schwarz"
    "ProductName"="FileSync"
    "ProductVersion"="1.0"
    
    [$RootKey$\Packages\{7de5e018-ebb8-4478-ba36-bfc716f5a0f8}\SatelliteDll]
    "DllName"="FileSyncUI.dll"
    "Path"="$PackageFolder$"
    
    [$RootKey$\Menus]
    "{7de5e018-ebb8-4478-ba36-bfc716f5a0f8}"=", 1000, 1"
    
    [$RootKey$\InstalledProducts\FileSync]
    @="#100"
    "Package"="{7de5e018-ebb8-4478-ba36-bfc716f5a0f8}"
    "ProductDetails"="#102"
    "LogoID"="#400"
    "PID"="Unknown Product ID"
    "UseInterface"=dword:00000000
    
    
    [$RootKey$\ToolWindows\{e767e32b-8528-47dc-9b83-0edc9e95135b}]
    @="{7de5e018-ebb8-4478-ba36-bfc716f5a0f8}"
    "Name"="FileSync"
    "Float"="100,100,300,400"
    "Orientation"="Right"
    "Style"="Float"
    "Window"="{4A9B7E51-AA16-11D0-A8C5-00A0C921A4D2}"
    //The GUID above is the TaskList GUID. You can replace it with any tool 
    //  window GUID to have the new window dock to that tool window.
    
    
    
    [$RootKey$\Editors\{3406e3ee-6a13-4b0d-9b41-36c09e824b7d}]
    @="FileSync"
    "Package"="{7de5e018-ebb8-4478-ba36-bfc716f5a0f8}"
    "DisplayName"="FileSync"
    "ExcludeDefTextEditor"=dword:00000001
    "AcceptBinaryFiles"=dword:00000000
    
    //The GUID in the below registry entry is the GUID for the text 
    //  logical view, and can be changed to the view that is appropriate
    //  for your editor.
    [$RootKey$\Editors\{3406e3ee-6a13-4b0d-9b41-36c09e824b7d}\LogicalViews]
    "{7651A703-06E5-11D1-8EBD-00A0C90F26EA}"=""
    
    [$RootKey$\Editors\{3406e3ee-6a13-4b0d-9b41-36c09e824b7d}\Extensions]
    "filesync"=dword:00000032
    
    [$RootKey$\KeyBindingTables\{c444a248-8c2f-4bc7-8a95-2694ebc100f5}]
    @="#1"
    "AllowNavKeyBinding"=dword:00000000
    "Package"="{7de5e018-ebb8-4478-ba36-bfc716f5a0f8}"
    
    //The first GUID below is the GUID for the Miscellaneous Files project type, and can be changed
    //  to the GUID of any other project you wish.
    [$RootKey$\Projects\{A2FE74E1-B743-11d0-AE1A-00A0C90FFFC3}\AddItemTemplates\TemplateDirs\{7de5e018-ebb8-4478-ba36-bfc716f5a0f8}\/1]
    @="#100"
    "TemplatesDir"="$PackageFolder$\Templates"
    "SortPriority"=dword:00004E20
    
    
    [$RootKey$\AutoLoadPackages\{adfc4e65-0397-11d1-9f4e-00a0c911004f}]
    "{7de5e018-ebb8-4478-ba36-bfc716f5a0f8}"=dword:00000000
    

    Friday, September 5, 2014 7:01 PM
  • I meet the same condition. Carlos J. Quintero's answer  is almost right,but miss one line [ @="UICONTEXT_NoSolution" ] in the example.  So in your case you need add this at the last line.

    This problem bothers me a whole day. Until I searched the Visual Studio install files and found "BaseConfig.pkgdef" under the "Microsoft Visual Studio 10.0\Common7\IDE\ShellExtensions\Platform" folder. The section at line 2566 is the right answer:

    [$RootKey$\AutoLoadPackages\{ADFC4E64-0397-11D1-9F4E-00A0C911004F}]
    "{53544C4D-E3F8-4AA0-8195-8A8D16019423}"=dword:00000000
    @="UICONTEXT_NoSolution"

    By the way, I agree with you about C++ is an orphaned child. So hard to find an example.

    • Proposed as answer by poplar_ys Sunday, November 30, 2014 11:48 AM
    Sunday, November 30, 2014 11:43 AM