locked
Get current solution path RRS feed

  • Question

  • I am making a vsix project and for that I need to get the path of currently opened solution.

    DTE dte = (DTE)GetService(typeof(DTE)); string solutionDir = System.IO.Path.GetDirectoryName(dte.Solution.FullName);

    I tried this but GetService() method is not getting resolved.

    How to get the current solution path?

    Saturday, March 17, 2018 2:25 PM

Answers

  • Hi Abhiprae Choudhury,

    >>How to get the current solution path?

    I am not sure what kind of vsix project you are using, if you use custom command, please refer to the following code.

     DTE2 dte = (DTE2)this.ServiceProvider.GetService(typeof(DTE));
    string solutionDir = System.IO.Path.GetDirectoryName(dte.Solution.FullName);
    
    

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 19, 2018 7:04 AM

All replies

  • Hi friend,

    Welcome to the MSDN forum.

    It seems your issue is about the VS extension development, since our forum is to discuss the VS IDE, I will help you move this thread to the appropriate forum for a better support, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Monday, March 19, 2018 6:28 AM
  • Thanks for moving the thread !

    Monday, March 19, 2018 6:34 AM
  • Hi Abhiprae Choudhury,

    >>How to get the current solution path?

    I am not sure what kind of vsix project you are using, if you use custom command, please refer to the following code.

     DTE2 dte = (DTE2)this.ServiceProvider.GetService(typeof(DTE));
    string solutionDir = System.IO.Path.GetDirectoryName(dte.Solution.FullName);
    
    

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 19, 2018 7:04 AM
  • I am using Custom Command, and I tried this method. 

    But while executing I am getting the following error in the second line:

    System.ArgumentException: 'The path is not of a legal form.'

    Monday, March 19, 2018 8:00 AM
  • Hi Abhiprae Choudhury,

    >>But while executing I am getting the following error in the second line:System.ArgumentException: 'The path is not of a legal form.'

    Do you open a solution when you debugger the vsix application on opened visual studio instance.

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 19, 2018 9:05 AM
  • Hi Zhanglong Wu,

    Yeah that was the problem, Thanks !

    Monday, March 19, 2018 4:57 PM