locked
[VSPackage]How to make sure a vspackage to be load at first in the vsshell? RRS feed

  • Question

  • In the vsshell,  I create 3 vspackage, How can I make  a vspackage to be load earlier than the other two vspackage?

    does it exsit  some attributes in the vspackage that  I can set  to make this package to be load firstly?

    Wednesday, January 26, 2011 3:09 AM

Answers

  • Hi Andrea,

    While you can load a package programatically via the IVsShel.LoadPackage API, there are propbably few legitimate reasons for wanting to do so. Apart from the LoadPackage method, there is no scenario that will allow you to prioritize the load order of the various packages that can be loaded into the IDE>

    The VS environment has been architected to facilitate a 'load on demand' scenario, and that is the scenario your package(s) should adhere to. That is, you should only load your package when the services it provides are actually required.  To do otherwise, unecessarily increases the memory requirements of the shell, and can also make the IDE appear less responsive when your packages are loaded.

    Consider a user that isn't necessarily using your feature/extension. Does your package get loaded regardless? If so, you may want to rethink your design. With that all being said, is there a particular reason why you need this one particular package loaded before the others?

    Sincerely,


    Ed Dore
    • Marked as answer by andrea sang Thursday, January 27, 2011 1:12 AM
    Wednesday, January 26, 2011 4:04 AM
  • You can probably use VisibilityItems and have package A set a UIContext  (or UIContexts plural) that communicate information about whether given commands should be visible.  Then in your VSCT for package B and C they simply have VisibilityItem entries for those UI Contexts  in their VSCT.  This is actually better as it prevents the packages (B and C) loading entirely.  They will only be loaded if some command they contribute is executed or some service they provide is needed, which is the intended model.

    Ryan

    • Marked as answer by andrea sang Thursday, January 27, 2011 1:12 AM
    Wednesday, January 26, 2011 6:20 AM

All replies

  • Hi Andrea,

    While you can load a package programatically via the IVsShel.LoadPackage API, there are propbably few legitimate reasons for wanting to do so. Apart from the LoadPackage method, there is no scenario that will allow you to prioritize the load order of the various packages that can be loaded into the IDE>

    The VS environment has been architected to facilitate a 'load on demand' scenario, and that is the scenario your package(s) should adhere to. That is, you should only load your package when the services it provides are actually required.  To do otherwise, unecessarily increases the memory requirements of the shell, and can also make the IDE appear less responsive when your packages are loaded.

    Consider a user that isn't necessarily using your feature/extension. Does your package get loaded regardless? If so, you may want to rethink your design. With that all being said, is there a particular reason why you need this one particular package loaded before the others?

    Sincerely,


    Ed Dore
    • Marked as answer by andrea sang Thursday, January 27, 2011 1:12 AM
    Wednesday, January 26, 2011 4:04 AM
  • Hi Ed Dore,

    thank you for your answer firstly,  My solution can be described as follows:

    package A provide the services include     check out  whether it is a legitimate user  and   get  the permission  of the legitimate user .  If he is not a legitimate user,  software window should be closed and quit.

    package B and Package C at first get the permission of legitimate user and then insert some commands to the visual studio tool window,  for different level user,  the tool commands which he can see is different  according to the permission get from package A.

    so while the shell start up ,  package A B C must be load at the same time ,   but Package B and   C  need  to call the service in 'A' to decide what commands can be seen by user.

    If I do not firstly load A,  how can I implement the above process and functions

    Sincerely,

    Wednesday, January 26, 2011 6:11 AM
  • You can probably use VisibilityItems and have package A set a UIContext  (or UIContexts plural) that communicate information about whether given commands should be visible.  Then in your VSCT for package B and C they simply have VisibilityItem entries for those UI Contexts  in their VSCT.  This is actually better as it prevents the packages (B and C) loading entirely.  They will only be loaded if some command they contribute is executed or some service they provide is needed, which is the intended model.

    Ryan

    • Marked as answer by andrea sang Thursday, January 27, 2011 1:12 AM
    Wednesday, January 26, 2011 6:20 AM