none
ActiveSolutionProjects ComException H_RESULT E_FAIL

    Question

  • Array projects = (Array)_applicationObject.ActiveSolutionProjects;
    


    I have this code in my add-in , _applicationObject is the DTE2 object passed to the add-in OnConnection.

    One user has report that the add-in throws a ComException with H_RESULT  E_FAIL at this point, i was not able to reproduce the problem, what could cause the exception? must i check ActiveSolutionProjects isn't null before do the cast?

    Monday, January 02, 2012 6:45 PM

Answers

  • Did you check my guess above that it has to do with the solution explorer not being visible in the IDE or it being set to auto-hide and having never been shown during the session when you get E_FAIL?

    Ryan

    Wednesday, January 04, 2012 11:18 PM
    Moderator

All replies

  • Hi pepone.onrez,

    I try to create a simple add in, and use the “Array projects = (Array)_applicationObject.ActiveSolutionProjects;” everything is ok.

    Without more information ,it is hard to find which part causes this issue.

    But you can ask your user try to restart his IIS, see whether can solve this issue.

    If this issue remain, you can ask your user try to reinstall this add-in, see whether this issue remains.

    See whether the following links are helpful:

    COMException error messages

    http://blogs.msdn.com/b/jaredpar/archive/2005/03/25/402386.aspx

    COMException Class

    http://msdn.microsoft.com/en-us/library/02hkayhc(v=VS.90).aspx

    Please mark the useful reply as answer.

    Thank you for your understanding!

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, January 04, 2012 3:59 AM
    Moderator
  • Is the solution explorer not visible in the IDE?  Or has it been set up to Auto-Hide and never displayed in the session when this happens?  It looks like ActiveSolutionProjects relies on being able to find the solution explorer window, if it can't it won't force its creation and will fail with E_FAIL.

    Ryan

    Wednesday, January 04, 2012 5:06 AM
    Moderator
  • My add-in is a Visual Studio add-in, and the problem happens when add an item to a C++ project, and the add-in try to get the active project, so seems total unrelated to IIS
    Wednesday, January 04, 2012 5:09 PM
  • Did you check my guess above that it has to do with the solution explorer not being visible in the IDE or it being set to auto-hide and having never been shown during the session when you get E_FAIL?

    Ryan

    Wednesday, January 04, 2012 11:18 PM
    Moderator
  • Hello Ryan,

    I was also experiencing this sporadic exception in my own add-in and today I have verified that your guessing was right, the problem happens when the Solution Explorer has not been displayed.

    Thank you very much for the conjecture.

    Best regards,

    Carlos


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    Friday, April 06, 2012 10:01 PM
    Moderator
  • I would file a Connect bug (external bugs have more weight than internal ones or I would file it myself).  I just guessed based on looking at the code path in question, but it seems odd that it should matter, it seems DTE could 'force create' anything it needed if the solution explorer hadn't yet been created when it got the call, it just happens to not do that in its current incarnation.

    Ryan

    Saturday, April 07, 2012 12:56 AM
    Moderator
  • Actually I filed two separate bugs at Microsoft Connect shortly after answering you, when I realized that this could not be a "by design" issue, since it doesn't make sense and VS 2005/2008 worked fine. VS 11 Beta works only half-fine, see my blog post:

    Bugs with the EnvDTE.DTE.ActiveSolutionProjects property with VS 2010 and VS 11 Beta
    http://msmvps.com/blogs/carlosq/archive/2012/04/06/bugs-with-the-envdte-dte-activesolutionprojects-property-with-vs-2010-and-vs-11-beta.aspx

    Best regards,

    Carlos


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    Monday, April 09, 2012 1:54 PM
    Moderator
  • I also ran into a problem with EnvDTE._DTE::get_ActiveSolutionProjects at startup Code Analysis. Details about what is causing the problem can be found here
    Monday, April 30, 2012 2:39 PM