Visual Studio Automation and Extensibility 
Attaching to Specific Instances of the IDE 

There are two ways to attach to a specific instance of the Visual Studio integrated development environment (IDE) when multiple instances are running.

Both of these methods use monikers. A moniker is a name that is bound to an object — in this case, the IDE — that can be used to locate, activate, and access the bound object. You do not need specific information about the location of the actual object. In this regard, it works like a shortcut does with a program in Windows.

There are two ways to attach to a specific instance of the IDE:

  • Use the solution file path moniker.

  • Use the item moniker.

Solution Path Moniker

If the instance of the Visual Studio IDE to which you want to attach has an open solution, then you can attach to it by using the solution file path moniker. That file moniker is registered in the running object table (ROT) with the solution object for that file. Use Solution.DTE to get to that object.

Item Moniker

Visual Studio also registers a ProgID as an item moniker in the ROT. The ProgID is comprised of the name and process ID of the DTE process. So, for example, the object's ROT entry might be "VisualSutdio.DTE.8.0!1234," where 1234 is the process ID.

See Also

Tags :


Community Content

bobthebob
Incorrect information.

The progID for the Item Moniker is not "VisualStudio.DTE.8.0!1234" as stated above, it should actually read: !VisualStudio.DTE.8.0:1234

Attempting to retrieve the object from the ROT with the progID stated above results in an exception with the message:

Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))

Check this forum post for more information on how to attach to a specific Visual Studio DTE instance:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1792508&SiteID=1

Tags : contentbug

Page view tracker