Visual Studio Tools for Office Runtime Overview

To run solutions that are created by using the Microsoft Office developer tools in Visual Studio 2010, the Visual Studio 2010 Tools for Office Runtime must be installed on end user computers. The Visual Studio 2010 Tools for Office Runtime consists of two main components:

  • The Office extensions for the .NET Framework. These components are managed assemblies that provide the communication layer between your solution and the Microsoft Office application. For more information, see Understanding the Office Extensions for the .NET Framework.

  • The Office solution loader. This component is a set of unmanaged DLLs that Office applications use to load the runtime and your solutions. For more information, see Understanding the Office Solution Loader.

The runtime can be installed in several different ways. Depending on the configuration of the computer, different runtime components are installed when you install the runtime. For more information, see Visual Studio Tools for Office Runtime Installation Scenarios.

Understanding the Office Extensions for the .NET Framework

The Visual Studio 2010 Tools for Office Runtime includes two Office extensions for the .NET Framework:

  • The Office extensions for the .NET Framework 3.5 are used by solutions that target the .NET Framework 3.5.

  • The Office extensions for the .NET Framework 4 are used by solutions that target the .NET Framework 4.

These extensions consist of assemblies that your solutions use to automate and extend Office applications. When you create an Office project, Visual Studio automatically adds references to the assemblies that are used for the project type and the target .NET Framework of the project. For more information about the assemblies in the Office extensions, see Assemblies in the Visual Studio Tools for Office Runtime.

Design Differences in the Office Extensions

Most of the types that you use in the Office extensions for the .NET Framework 3.5 are classes. These are the same classes that were included in previous versions of the Visual Studio Tools for Office runtime. In contrast, most of the types that you use in the Office extensions for the .NET Framework 4 are interfaces. For example, when you target the .NET Framework 4, the Microsoft.Office.Tools.Excel.Worksheet and Microsoft.Office.Tools.Word.Document types are interfaces instead of classes.

In most cases, the code you write in Office solutions is the same whether your solution targets the .NET Framework 3.5 or the .NET Framework 4. However, certain features require different code when you target different versions of the .NET Framework. For more information, see Migrating Office Solutions to the .NET Framework 4.

Interfaces in the Office Extensions for the .NET Framework 4

Most of the interfaces in the Office extensions for the .NET Framework 4 are not intended to be implemented by user code. The only interfaces you can implement directly have names that begin with the letter I, such as ISmartTagExtension.

All interfaces that do not begin with the letter I are implemented internally by the Visual Studio 2010 Tools for Office Runtime, and these interfaces might change in future releases. To create objects that implement these interfaces, use methods provided by the Globals.Factory object in your project. For example, to get an object that implements the SmartTag interface, use the Globals.Factory.CreateSmartTag method. For more information about Globals.Factory, see Global Access to Objects in Office Projects.

Enabling Type Equivalence and Embedded Types in Projects that Target the .NET Framework 4

The interface-based object model of the Office extensions for the .NET Framework 4 enables you to use the type equivalence feature in Visual C# 2010 and Visual Basic 2010 to embed type information from the Visual Studio Tools for Office runtime into your solution. This feature enables Office solutions and the Visual Studio Tools for Office runtime to version independently of each other. For example, if your solution uses the Microsoft.Office.Tools.Word.Document interface as an embedded type and the next version of the runtime adds members to the Microsoft.Office.Tools.Word.Document interface, your solution will still work with the next version of the runtime. If your solution does not use the Microsoft.Office.Tools.Word.Document interface as an embedded type, then your solution will no longer work with the next version of the runtime.

By default, the type equivalence feature is not enabled when you create an Office project that targets the .NET Framework 4. If you want to enable this feature, set the Embed Interop Types property of any of the following assembly references in your project to True:

  • Microsoft.Office.Tools.dll

  • Microsoft.Office.Tools.Common.dll

  • Microsoft.Office.Tools.Excel.dll

  • Microsoft.Office.Tools.Outlook.dll

  • Microsoft.Office.Tools.Word.dll

After you make this change, type information for all of the runtime types used by the project is embedded into the solution assembly when you build the project. This embedded type information, rather than the type information in the referenced assemblies, are used by the solution at run time.

Understanding the Office Solution Loader

The Visual Studio Tools for Office runtime includes several unmanaged DLLs that Office applications use to load the runtime and Office solutions. Although you should never have to work with these DLLs directly, knowing the purposes of these DLLs can help you better understand the architecture of Office solutions.

For information about how these components are used during the load process, see Architecture of Document-Level Customizations and Architecture of Application-Level Add-Ins.

VSTOEE.dll

When a user opens a document-level customization or starts an add-in, the Office application calls into VSTOEE.dll to perform the tasks required to load the Visual Studio Tools for Office runtime.

VSTOEE.dll makes sure that the correct version of the Visual Studio Tools for Office runtime is loaded for the solution and the installed version of Office. Although multiple versions of the Visual Studio Tools for Office runtime can be installed on the same computer, only one instance of VSTOEE.dll is installed at a time. This is the VSTOEE.dll that was included with the latest version of the runtime installed on the computer. For more information about the different versions of the Visual Studio Tools for Office runtime that can be used for other solutions, see Running Solutions in Different Versions of Microsoft Office.

VSTOLoader.dll

After VSTOEE.dll loads the appropriate version of the Visual Studio Tools for Office runtime, VSTOLoader.dll performs most of the work that is required to load the solution assembly. VSTOLoader.dll does several things:

  • It creates an application domain for each solution assembly.

  • It performs a set of security checks to verify that the solution assembly has permission to run.

  • It loads the version of the Office extensions for the .NET Framework that is required by the solution.

VSTOLoader.dll also does several things that are specific to add-ins:

  • It implements the IDTExtensibility2 interface. IDTExtensibility2 is a COM interface that all add-ins for Microsoft Office applications must implement. This interface defines methods that the application calls to communicate with the add-in.

  • It implements the IManagedAddin interface. This interface is used by Office applications to help load application-level add-ins. For more information, see IManagedAddin Interface.

Understanding the 32-bit and 64-bit Versions of the Runtime

There are separate 64-bit and 32-bit versions of the Visual Studio 2010 Tools for Office Runtime. These versions of the runtime are used to run solutions in 64-bit and 32-bit editions of Microsoft Office 2010. The following table shows which version of the runtime is required for each combination of Microsoft Windows and Microsoft Office 2010.

Edition of Microsoft Windows

Edition of Microsoft Office

Required version of the Visual Studio Tools for Office runtime

32-bit

32-bit

32-bit

64-bit

32-bit

64-bit

64-bit

64-bit

64-bit

When you install Microsoft Office 2010, the required version of the Visual Studio Tools for Office runtime is installed along with Office. For example, when you install the 64-bit edition of Microsoft Office 2010 on a 64-bit version of Microsoft Windows, the 64-bit version of the Visual Studio Tools for Office runtime is also installed. For more information about installing the Visual Studio Tools for Office runtime with Microsoft Office 2010, see Visual Studio Tools for Office Runtime Installation Scenarios.

The 64-bit version of Microsoft Office 2010 can also run Office solutions that were created by using project templates for the 2007 Microsoft Office system in Visual Studio 2008. However, it cannot run Office solutions created by using project templates for Microsoft Office 2003 in Visual Studio 2008, or Office solutions created by using Visual Studio 2005. For more information, see Running Solutions in Different Versions of Microsoft Office.

Repairing the Visual Studio 2010 Tools for Office Runtime

If you need to repair the runtime, open Programs and Features or Add or Remove Programs in the Control Panel, select Microsoft Visual Studio 2010 Tools for Office Runtime in the list of programs, and then click Uninstall. The setup program that runs enables you to repair the runtime. If you click Change, you are not given an option for repairing the runtime.

See Also

Tasks

How to: Create Office Projects in Visual Studio

Concepts

Visual Studio Tools for Office Runtime Installation Scenarios

Assemblies in the Visual Studio Tools for Office Runtime

Architecture of Document-Level Customizations

Architecture of Application-Level Add-Ins

Other Resources

Architecture of Office Solutions in Visual Studio

Upgrading and Migrating Office Solutions