Configuring a Computer to Develop Office Solutions
You must install the following prerequisites before you can use the Microsoft Office developer tools in Visual Studio 2010:
-
Visual Studio
-
.NET Framework
-
Microsoft Office
For most development tasks, you must also install and register the primary interop assemblies for Microsoft Office in the global assembly cache.
The Office developer tools are included only with the following editions of Visual Studio 2010:
-
Visual Studio 2010 Professional
-
Visual Studio 2010 Premium
-
Visual Studio 2010 Ultimate
Visual Studio
The Office developer tools are an optional component of Visual Studio. These tools are installed by default when you install one of the Visual Studio editions listed above. If you customize the Visual Studio installation by selecting which features to install, select Microsoft Office Developer Tools during setup to install the tools.
The Office developer tools include the Visual Studio Tools for Office runtime and features that are integrated into Visual Studio itself, such as project templates and designers.
.Net Framework
You can use the Office developer tools in Visual Studio 2010 to create solutions that target the .NET Framework 3.5 or the .NET Framework 4. The .NET Framework 4 is automatically installed when you install Visual Studio 2010. If you want to create solutions that target the .NET Framework 3.5, you must make sure this version of the framework is installed on the development computer too.
Microsoft Office
You can use Visual Studio 2010 to create solutions for Microsoft Office 2010 and the 2007 Microsoft Office system.
You must have one of the following versions of Office installed locally on the development computer:
-
Any suite edition of the 2007 Microsoft Office system or Microsoft Office 2010
-
Any of the following standalone applications:
-
Excel 2007 or Excel 2010
-
InfoPath 2007 or InfoPath 2010
-
Outlook 2007 or Outlook 2010
-
PowerPoint 2007 or PowerPoint 2010
-
Project 2007 or Project 2010
-
Visio 2007 or Visio 2010
-
Word 2007 or Word 2010
-
Visual Basic for Applications (VBA) must be installed as part of Office.
Visual Studio 2010 does not support creating Office solutions for Microsoft Office 365 or a version of Microsoft Office 2010 that was delivered via Click-to-Run.
Note:
Visual Studio 2010 does not support creating Office solutions when Microsoft Office 2010 and the 2007 Microsoft Office system (or different versions of individual Office applications, such as Excel 2007 and Excel 2010) are installed side-by-side on the development computer. To create Office solutions by using the Office developer tools in Visual Studio 2010, install just one version of Office on the development computer.
Although you can install only one version of Office on the development computer, you can create Office solutions that run in both Microsoft Office 2010 and the 2007 Microsoft Office system on end user computers. For more information, see Running Solutions in Different Versions of Microsoft Office.
Primary interop assemblies for MS Office
The Office primary interop assemblies (PIAs) must be installed and registered in the global assembly cache to perform the following development tasks:
-
To create a document-level project.
-
To run or debug any Office project that targets the .NET Framework 3.5.
-
To run or debug any Office project that targets the .NET Framework 4, and in which you have changed the Embed Interop Types property of all the PIA references in your project to False.
You can create and build application-level projects without having the PIAs installed in the global assembly cache. However, if you do this, you cannot run or debug the projects in the scenarios listed above.
When you install Office on the development computer, the PIAs are installed and registered in the global assembly cache by default in the following cases:
-
The .NET Framework 1.1 or later is installed before you install the 2007 Microsoft Office system.
-
The .NET Framework 2.0 or later is installed before you install Microsoft Office 2010.
If you install Office on a development computer that does not have the .NET Framework installed yet, or if you modify Office setup to not install the PIAs, you must install the primary interop assemblies separately.
Office Primary Interop Assemblies
To use the features of a Microsoft Office application from an Office project, you must use the primary interop assembly (PIA) for the application. The PIA enables managed code to interact with a Microsoft Office application's COM-based object model.
When you create a new Office project, Visual Studio adds references to the PIAs that are required to build the project. In some scenarios, you might need to add references to additional PIAs (for example, if you want to use a feature of Microsoft Office Word in a project for Microsoft Office Excel).
Primary Interop Assemblies in the Program Files Directory
When you install Visual Studio, the PIAs are automatically installed to a location in the file system, outside of the global assembly cache. When you create a new project, Visual Studio automatically adds references to these copies of the PIAs to your project. Visual Studio uses these copies of the PIAs, instead of the assemblies in the global assembly cache, to resolve type references when you develop and build your project.
These copies of the PIAs help Visual Studio avoid several development issues that can occur when different versions of the PIAs are registered in the global assembly cache.
Visual Studio installs these copies of PIAs to the following locations on the development computer:
-
%ProgramFiles%\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office12
(or %ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office12 on 64-bit operating systems)
-
%ProgramFiles%\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14
(or %ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14 on 64-bit operating systems)
Primary Interop Assemblies in the Global Assembly Cache
To perform certain development tasks, the PIAs must be installed and registered in the global assembly cache on the development computer. Typically, the PIAs are installed automatically when you install Office on the development computer.
End-user computers must also have the PIAs installed and registered in the global assembly cache to run Office solutions that target the .NET Framework 3.5. However, the Office PIAs are not required on end-user computers to run Office solutions that target the .NET Framework 4.
In most cases, you should add references to the PIAs that are installed by Visual Studio under the %ProgramFiles%\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\ directory. These versions of the assemblies appear on the .NET tab of the Add Reference dialog box.
If you have installed and registered the PIAs in the global assembly cache, these versions of the assemblies appear on the COM tab of the Add Reference dialog box. You should avoid adding references to these versions of the assemblies, because there are some development issues that can occur when you use them. For example, if you have registered different versions of the PIAs in the global assembly cache, your project will automatically bind to the version of the assembly that was registered last—even if you specify a different version of the assembly on the COM tab of the Add Reference dialog box.
The following table lists the primary interop assemblies that are available for Microsoft Office 2010 and the 2007 Microsoft Office system.
Office application or component |
Primary interop assembly name |
---|---|
Microsoft Access 12.0 Object Library Microsoft Access 14.0 Object Library |
Microsoft.Office.Interop.Access.dll |
Microsoft Office 2007 Access Database Engine Object Library Microsoft Office 14.0 Access Database Engine Object Library |
Microsoft.Office.Interop.Access.Dao.dll |
Microsoft Excel 12.0 Object Library Microsoft Excel 14.0 Object Library |
Microsoft.Office.Interop.Excel.dll |
Microsoft Graph 12.0 Object Library (used by PowerPoint, Access, and Word for graphs) Microsoft Graph 14.0 Object Library |
Microsoft.Office.Interop.Graph.dll |
Microsoft InfoPath 2.0 Type Library (for InfoPath 2007 only) |
Microsoft.Office.Interop.InfoPath.dll |
Microsoft InfoPath XML Interop Assembly (for InfoPath 2007 only) |
Microsoft.Office.Interop.InfoPath.Xml.dll |
Microsoft Office 12.0 Object Library (Office shared functionality) Microsoft Office 14.0 Object Library (Office shared functionality) |
office.dll |
Microsoft Office Outlook View Control (can be used in Web pages and applications to access your Inbox) |
Microsoft.Office.Interop.OutlookViewCtl.dll |
Microsoft Outlook 12.0 Object Library Microsoft Outlook 14.0 Object Library |
Microsoft.Office.Interop.Outlook.dll |
Microsoft PowerPoint 12.0 Object Library Microsoft PowerPoint 14.0 Object Library |
Microsoft.Office.Interop.PowerPoint.dll |
Microsoft Project 12.0 Object Library Microsoft Project 14.0 Object Library |
Microsoft.Office.Interop.MSProject.dll |
Microsoft Publisher 12.0 Object Library Microsoft Publisher 14.0 Object Library |
Microsoft.Office.Interop.Publisher.dll |
Microsoft SharePoint Designer 12.0 Web Object Reference Library Microsoft SharePoint Designer 14.0 Web Object Reference Library |
Microsoft.Office.Interop.SharePointDesigner.dll |
Microsoft SharePoint Designer 12.0 Page Object Reference Library Microsoft SharePoint Designer 14.0 Page Object Reference Library |
Microsoft.Office.Interop.SharePointDesignerPage.dll |
Microsoft Smart Tags 2.0 Type Library Note
Smart tags are deprecated in Excel 2010 and Word 2010. For more information, see Smart Tags Overview.
|
Microsoft.Office.Interop.SmartTag.dll |
Microsoft Visio 12.0 Type Library Microsoft Visio 14.0 Type Library |
Microsoft.Office.Interop.Visio.dll |
Microsoft Visio 12.0 Save As Web Type Library Microsoft Visio 14.0 Save As Web Type Library |
Microsoft.Office.Interop.Visio.SaveAsWeb.dll |
Microsoft Visio 12.0 Drawing Control Type Library Microsoft Visio 14.0 Drawing Control Type Library |
Microsoft.Office.Interop.VisOcx.dll |
Microsoft Word 12.0 Object Library Microsoft Word 14.0 Object Library |
Microsoft.Office.Interop.Word.dll |
Microsoft Visual Basic for Applications Extensibility 5.3 |
Microsoft.Vbe.Interop.dll |
Binding Redirect Assemblies
When you install and register the Office PIAs in the global assembly cache (either with Office or by installing the redistributable package for the PIAs), the binding redirect assemblies are also installed only in the global assembly cache. These assemblies help make sure that the correct version of the primary interop assemblies are loaded at run time. For example, when a solution that references a 2007 Microsoft Office primary interop assembly runs on a computer that has the Microsoft Office 2010 version of the same primary interop assembly, the binding redirect assembly instructs the .NET Framework runtime to load the Microsoft Office 2010 version of the primary interop assembly. For more information, see Assembly Binding Redirection.
Each binding redirect assembly has a name in the format Policy.11.0.PIA Name.dll or Policy.12.0.PIA Name.dll, such as Policy.11.0.Microsoft.Office.Interop.Excel.dll and Policy.12.0.Microsoft.Office.Interop.Excel.dll.
posted on 2012-08-13 15:35 malaikuangren 阅读(526) 评论(0) 编辑 收藏 举报