Search code examples
c#visual-studioprojects-and-solutions

Is there a way to programmatically see what solution an instance of Visual Studio has open (not as a plugin)?


Pretty straight-forward, but don't really know if it's even feasible. Basically I'd like to have a winform (NOT a plugin to VS) that retrieves a list of of solutions that are currently loaded in open instances of Visual Studio.

EDIT: To clarify per comments below, I'm looking for the loaded solutions full path (e.g., C:\projects\myrandomproject.sln


Solution

  • You can enumerate the running instances of Visual Studio through the running object table (ROT). See IRunningObjectTable and GetRunningObjectTable.

    You can then get a reference to the DTE2 object for each running instance using the identifier from the ROT.

    Use DTE2.Solution. You can get its path from its FullName property.