views:

21

answers:

1

I am attempting my first Visual Studio 2010 plugin and am attempting to reference the ActiveSolutionProjects like so

    private DTE2 _applicationObject;

        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
             _applicationObject = (DTE2)application;
             ...
        }

   private void load()
   {         
       var theProjects = (System.Array)_applicationObject.ActiveSolutionProjects;
       ...
    }

The

var theProjects = (System.Array)_applicationObject.ActiveSolutionProjects;

line fails with

Error HRESULT E_FAIL has been returned from a call to a COM component. ErrorCode -2147467259

Any idea how I fix this error?

A: 

The issue is there is no active solution selected and a null reference issue. I just wrapped the call in an exception handler and am investigating how to set the active solution through automation.

Kenoyer130