Dela via


Visual Studio Tools for Office runtime overview

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

To run solutions that are created by using the Microsoft Office developer tools in Visual Studio, the Visual Studio 2010 Tools for Office runtime must be installed on end-user computers. For more information, see How to: Install the Visual Studio Tools for Office runtime redistributable. The Visual Studio 2010 Tools for Office runtime consists of two main components:

Understand the Office extensions for the .NET Framework

The Visual Studio 2010 Tools for Office runtime includes Office extensions for the .NET Framework 3.5, the .NET Framework 4 and later. Solutions that target each version of the .NET Framework use the appropriate extensions for that version.

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 or later are interfaces. For example, when you target the .NET Framework 4 or later, the Worksheet and 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 Migrate Office solutions to the .NET Framework 4 or later.

Interfaces in the Office extensions for the .NET Framework 4 or later

Most of the interfaces in the Office extensions for the .NET Framework 4 or later 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.

Enable type equivalence and embedded types in projects that target the .NET Framework 4 or later

Because the object model of the Office extensions for the .NET Framework 4 or later are based on interfaces, you can use the type equivalence feature in both Visual C# and Visual Basic in Visual Studio 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 Document interface as an embedded type and the next version of the runtime adds members to the Document interface, your solution will still work with the next version of the runtime. If your solution does not use the 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 or later. 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.

Understand 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 VSTO Add-ins.

VSTOEE.dll

When a user opens a document-level customization or starts a VSTO 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 Run 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 VSTO Add-ins:

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

  • It implements the IManagedAddin interface. This interface is used by Office applications to help load VSTO Add-ins. For more information, see IManagedAddin interface.

Understand 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 Office. The following table shows which version of the runtime is required for each combination of Windows and Office.

Edition of 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 Office, 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 Office on a 64-bit version of 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 Office, see Visual Studio Tools for Office runtime installation scenarios.

The 64-bit version of Office 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 Run solutions in different versions of Microsoft Office.

Repair 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