Attaching to Specific Instances of the IDE

Visual Studio add-ins are deprecated in Visual Studio 2013. You should upgrade your add-ins to VSPackage extensions. For more information about upgrading, see FAQ: Converting Add-ins to VSPackage Extensions.

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 "!VisualStudio.DTE.10.0:1234," where 1234 is the process ID.

See Also

Tasks

How to: Get References to the DTE and DTE2 Objects

Other Resources

Referencing Automation Assemblies and the DTE2 Object