locked
restart vs after package installation RRS feed

  • Question

  • How do I restart VS after performing package upgrade using IVsExtensionRepository? As I see it the Install() method returns RestartReason enum, but how do I actually make use of it?
    Friday, March 29, 2013 9:50 AM

Answers

  • Odd, I am surprised that interface is even public, and MSDN even says

    Although this API supports the Extension Manager infrastructure, we recommend that you do not use it because it is subject to change.

    That said, you can ask the shell to restart using IVsShell4::Restart method.

    • Proposed as answer by Ego Jiang Monday, April 1, 2013 2:12 AM
    • Marked as answer by Ego Jiang Tuesday, April 2, 2013 9:15 AM
    Friday, March 29, 2013 5:20 PM
  • Try asking for typeof(SVsShell), a service identifier (SVs<something>) and some interface that said service happens to implement are not always equal (sometimes they are).

    • Proposed as answer by Yann Duran Monday, April 1, 2013 10:42 AM
    • Marked as answer by Ego Jiang Tuesday, April 2, 2013 9:15 AM
    Monday, April 1, 2013 5:17 AM

All replies

  • Odd, I am surprised that interface is even public, and MSDN even says

    Although this API supports the Extension Manager infrastructure, we recommend that you do not use it because it is subject to change.

    That said, you can ask the shell to restart using IVsShell4::Restart method.

    • Proposed as answer by Ego Jiang Monday, April 1, 2013 2:12 AM
    • Marked as answer by Ego Jiang Tuesday, April 2, 2013 9:15 AM
    Friday, March 29, 2013 5:20 PM
  • Hi Ryan,

    This is something that I was looking for, but had put on a back burner. I stumbled across this thread by (happy) accident.

    I'm having trouble doing what you said "ask the shell to restart using IVsShell4::Restart method". I can't seem to get an actual instance to execute the Restart method from.

    In my package code, I've tried:

    var _shell = (IVsShell4)GetGlobalService(typeof(IVsShell4));

    as well as:

    var _shell = (IVsShell4)this.GetService(typeof(IVsShell4));

    Both return null instead of an instance.

    In my command's execution code I have:

    var mode = (uint)__VSRESTARTTYPE.RESTART_Normal;
    if (ErrorHandler.Failed(_shell.Restart(mode))) ShowMessage("Error occurred during restart");

    It looks like it would run if I was successfully able to get an instance of IVsShell4. What am I doing wrong?

    TIA


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Monday, April 1, 2013 5:10 AM
  • Try asking for typeof(SVsShell), a service identifier (SVs<something>) and some interface that said service happens to implement are not always equal (sometimes they are).

    • Proposed as answer by Yann Duran Monday, April 1, 2013 10:42 AM
    • Marked as answer by Ego Jiang Tuesday, April 2, 2013 9:15 AM
    Monday, April 1, 2013 5:17 AM
  • Hi Ryan,

    Yes, I understand. That's helpful to know.

    Thank you, typeof(SVsShell) worked flawlessly! That's one I can cross off my list. :-)

    Thanks also for the extremely quick reply, I appreciate it.


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Monday, April 1, 2013 10:42 AM