Primary Interop Assemblies

Office applications, such as Word and Excel, are written in unmanaged code. For your VSTO solution (managed code) to interoperate with the unmanaged COM objects in the Office application, it must use an interoperability assembly. Visual Studio can create an interoperability assembly for you when you set a reference to a COM type library, but generating an interoperability assembly in this way is not recommended. Instead, you should use the official interoperability assembly that is provided by the publisher of the type library. This is known as the primary interop assembly (PIA). If the PIAs are installed on your computer and you set a reference to the type library, Visual Studio automatically loads the PIA instead of generating a new interop assembly.

Microsoft provides PIAs for its Office applications. The name of the Excel PIA is Microsoft.Office.Interop.Excel.dll. Word and Outlook follow the same naming convention for their PIAs: Microsoft.Office.Interop.Word.dll and Microsoft.Office.Interop.Outlook.dll.

The PIAs get installed in your computer's GAC when you run a complete installation of Office 2003. Whenever you create a new VSTO solution, Visual Studio automatically adds to your solution a reference to the appropriate Office PIA and any of its dependent assemblies. You can view the contents of the GAC by opening the Windows\assembly directory of your root drive. Figure 3.7 shows the Microsoft PIAs.

The namespace for these PIAs is determined by the name of the assembly. VSTO automatically creates an alias for these namespaces, as shown in Table 3.3.

If the PIAs have not been correctly installed on your development machine because a complete installation of Office 2003 was not performed, you can run a reinstall or repair of Office 2003, assuming that .NET Framework 1.1 or later is already installed on your computer. Alternatively, you can use Add or Remove Features in the Maintenance Mode Options section of the Microsoft Office 2003 Setup, and click Next (see Figure 3.8). For information on redistributing the PIAs when you deploy your solutions, see Chapter 11.

On the next page of the Setup wizard, select Choose Advanced Customization of Applications, and then click Next.

lb assembly

JnlxJl

1 File Edit View Favorites Tools Help

*

Back - - ^ JD Search [jP

Folders

eeM x Ü

Address C:\WINDOWS\assembly

JHGO

Assembly Name }

| Version

I Cul... | Public Key Token

1 Procès... 1

£l

M

crosoft.DataWarehouse.Interfaces

9.0.242.0

89845dcd8080cc91

MSIL

£l

M

crosoft.ExceptionMessageEiox

9.0.242.0

89845dcd8080cc91

MSIL

£l

M

crosoft.JScript

8.0.0.0

b03f5f7flld50a3a

MSIL

£l

M

crosoft.mshtml

7.0.33...

b03f5f7flld50a3a

£l

M

crosoft.MSXML

8.0.0.0

b03f5f7flld50a3a

MSIL

£l

M

crosoft. NetEnterpriseServers. ExceptionMess..

9.0.242.0

89845dcd8080cc91

MSIL

£l

M

crosoft. Office. Interop. Access

11.0.0.0

71e9bcel

le9429c

xk

Microsoft. Office. Interop. Excel

11.0.0.0

71e9bcel

le9429c

Mi

icrosoft. Office. Interop. Graph

11.0.0.0

71e9bcel

le9429c

Mi

icrosof t. Office. Interop. Inf oPath

11.0.0.0

71e9bcel

le9429c

£l

Mi

icrosoft. Office. Interop. Inf oPath. Xml

11.0.0.0

71e9bcel

le9429c

Microsoft.Office.Interop.Outlook

11.0.0.0

71e9bcel

le9429c

£l

Mi

crosoft. Office. Interop. OutlookViewCtl

11.0.0.0

71e9bcel

le9429c

£l

Mi

crosoft. Office. Interop. Owe 11

11.0.0.0

71e9bcel

le9429c

£l

Mi

crosoft. Office. Interop. PowerPoint

11.0.0.0

71e9bcel

le9429c

£l

Mi

crosoft. Office. Interop. Publisher

11.0.0.0

71e9bcel

le9429c

£l

Mi

crosoft. Office. Interop. SmartTag

11.0.0.0

71e9bcel

le9429c

£l

Mi

icrosoft. Office. Interop. Visio

11.0.0.0

71e9bcel

le9429c

£l

Mi

icrosoft. Office. Interop. Visio. SaveAsWeb

11.0.0.0

71e9bcel

le9429c

£l

Mi

icrosoft. Office. Interop. VisOcx

11.0.0.0

71e9bcel

le9429c

xk

Microsoft. Office. Interop. Word

11.0.0.0

71e9bcel

le9429c

£l

Mi

icrosoft. Office. Tools. Common

8.0.0.0

b03f5f7flld50a3a

MSIL

£l

Mi

icrosoft. Office. Tools. Excel

8.0.0.0

b03f5f7flld50a3a

MSIL

£l

Mi

icrosoft. Office. Tools. Outlook

8.0.0.0

b03f5f7flld50a3a

MSIL

(il

Mi

icrosoft. Office. Tools. Word

8.0.0.0

b03f5f7flld50a3a

MSIL

Figure 3.7. Microsoft Office PIAs displayed in the GAC

Table 3.3. Excel, Word, and Outlook PIAs, Namespaces, and Aliases

PIA

Namespace

Alias

Microsoft.Office.Interop.Excel.dll

Microsoft.Office.Interop.Excel

Excel

Microsoft.Office.Interop.Word.dll

Microsoft.Office.Interop.Word

Word

Microsoft.Office.Interop.Outlook.dll

Microsoft.Office.Interop.Outiook

Outlook

Set each of the following components to Run from My Computer. See Figure 3.9 for an example.

• Microsoft Office Excel | .NET Programmability Support

• Microsoft Office Outlook | .NET Programmability Support

Microsoft OFfke 2003 Setup

1 -!□!*!

Microsoft Office Professional Edition 2003

Hantenaxe Mode Opticas

LI

ChonQe vs+iich features are instaled or remove specific features.

ft f- Remstal or Repar

. Rénstal « Repa* Wcrosoft Office 2003 to its original stale.

■Sjtf Urnnstal Microsoft Office 2Û03 from this computer.

Figure 3.8. Maintenance Mode Options in Microsoft Office 2003 Setup

• Microsoft Office Word | .NET Programmability Support

• Office Tools | Microsoft Forms 2.0 .NET Programmability Support

• Office Tools | Smart Tag .NET Programmability Support

• Office Tools | Microsoft Graph, .NET Programmability Support

Microsoft OFFice 2003 Setup

Microsoft Office Professional Edition 2003

Advanced Custcrnfcation

OO

Choose update options for applications and tools.

Choose update options for applications and tools.

B »=>* I Microsoft Office m Werosctft Office Accew H Wcrosoft Office Excel

Run from My Computer tjfl Run all from My Computer

0_J Instaled on Frst Use

Hot Avalable

Description

Primary rterop assembly that allows Microsoft Office E:tcel pfegrarifnatiliy with .NET Framework version 1.1.

Space Requred en C: 1968 KB Space Avalable en C: 19 GB

Figure 3.9. Advanced Customization in Microsoft Office 2003 Setup

0 0

Post a comment