Share via


Updating a Host Application to Support Visual Studio Tools for Applications 2.0

If you have an application that you have already integrated Microsoft Visual Studio 2005 Tools for Application, you must make several changes to your existing implementation to support Visual Studio Tools for Applications. Perform the following tasks to support Microsoft Visual Studio Tools for Applications 2.0:

  • Move host configuration settings to a new registry key.

  • Update code in the host application project.

  • Create new add-in project templates.

For information about how to migrate add-in projects, see Migrating Add-in Projects.

Moving the Host Configuration Settings to a New Registry Key

The host configuration key stores the host ID and several other configuration settings. To support Microsoft Visual Studio Tools for Applications 2.0, you must add a new application-specific key under the host configuration key. You must then add new subkey named "2.0" to the new application-specific key as follows:

  • On 32-bit platforms:

    HKEY_LOCAL_MACHINE\Software\Microsoft\VSTAHostConfig\hostID\2.0

  • On 64-bit platforms:

    HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VSTAHostConfig\hostID\2.0

Move all entries and values from the hostID subkey to the hostID/2.0 subkey. You must then regenerate the host context registry hive. For more information, see Registering the Host Application.

Updating Code in the Host Application Project

You must update the following code in the host application project to support Microsoft Visual Studio Tools for Applications 2.0:

  • Code that discovers and loads add-ins.

  • Code that incorporates the Microsoft Visual Studio Tools for Applications 2.0 IDE.

Code That Discovers and Loads Add-Ins

Microsoft Visual Studio Tools for Applications 2.0 has renamed several assemblies, removed several types, and has added new types that improve the way a host application discovers and loads add-ins.

Microsoft Visual Studio Tools for Applications 2.0 uses a new add-in communication model that is based on the .NET Framework 3.5 add-in pipeline. To set up the host application to discover and load add-ins, you must replace all existing code that uses the AddIn and AddInCollection classes. The .NET Framework 3.5 and Microsoft Visual Studio Tools for Applications 2.0 use new classes to accomplish these tasks. You must also implement new interfaces to enable types and objects in the host application to be used by add-ins, and for types and objects in add-ins to be used by the host application.

For more information about how to modify your code to discover and load add-ins, see Discovering and Loading Add-Ins.

Code That Integrates the IDE

You must modify code that gets the Visual Studio Tools for Applications host adapter and facilitates the Microsoft Visual Studio Tools for Applications 2.0 debugger.

To get the Microsoft Visual Studio Tools for Applications 2.0 host adapter, you must pass the string "VSTAHostAdapter2007" to the Project.Extender method.

To integrate the host application with the Microsoft Visual Studio Tools for Applications 2.0 debugger, you must implement new methods in the IExternalDebugHost interface.

For more information, see Incorporating the Integrated Development Environment.

Creating New Add-in Project Templates

You must create new project templates that are compatible with Microsoft Visual Studio Tools for Applications 2.0. Perform the following tasks to create new project templates:

  • Generate new proxy assemblies.

  • Update in-process hosts.

  • Generate new project templates.

Creating New Proxy Assemblies

Proxy assemblies contain the object model of your host application that you expose to add-in developers.

The code that is generated by the Proxy Generation tool (Proxygen.exe) has changed. Therefore, you must generate new proxy assemblies before you can create new project templates. For more information, see Creating Proxies.

Updating In-Process Hosts

In-process hosts enable you to extend the Visual Studio Tools for Applications project system. If you created an in-process host by using Visual Studio 2005 Tools for Applications, you must perform the following tasks to ensure that it loads in a Microsoft Visual Studio Tools for Applications 2.0 add-in project:

  • Add a reference to the Microsoft.VisualStudio.Tools.Applications.DesignTime.v9.0 assembly.

  • Modify code in the in-process host class.

  • Modify the registry.

Modifying Code in the In-Process Host Class

You must modify your implementation of the SetAdapter method so that it receives an object that implements the IVstaHostAdapter interface. You must then cast the object to a HostAdapter.

The following code example illustrates these changes.

public class IPH : IInProcessHost
{
    private HostAdapter IPHHostAdapter;
    public void SetAdapter(IVstaHostAdapter hostAdapter)
    {
        this.IPHHostAdapter = (HostAdapter)hostAdapter;
    }
}

Install the in-process assembly to the global assembly cache. Then, add a key to the application-specific host configuration subkey. For more information about how to do this, see Creating In-Process Hosts.

Modifying the Registry

Add-in projects reference the GUID of the original in-process host. You must modify the registry to redirect add-in projects to the GUID of the updated in-process host.

To redirect add-ins to the updated in-process host, add a new key as follows:

  • On 32-bit platforms:

    HKEY_LOCAL_MACHINE\Software\Microsoft\VSTAHostConfig\hostID\2.0\VSTA\InProcHost\GUID.

  • On 64-bit platforms:

    HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VSTAHostConfig\hostID\2.0\VSTA\InProcHost\GUID.

The GUID key must match the GUID of the original in-process host. The GUID of the original in-process host is located under the hostID subkey.

Add an entry named Upgrade to the new in-process host key. Ensure that this entry has the type REG_SZ. Set the value of this entry to the GUID of the updated in-process host.

Run vsta.exe using the /hostid and /setup switch. For more information, see How to: Register the Host Application.

Creating New Project Templates

After you create a new proxy assembly and update your in-process hosts, you must generate new project templates. To do this, run the Project Generation tool (ProjectGen.exe). If you added any custom code to the original project templates, move that code over to the new project templates manually. For more information, see Creating Project Templates (Visual Studio Tools for Applications).

See Also

Concepts

Upgrading to Visual Studio Tools for Applications 2.0

Migrating Add-in Projects