Features in AH Releases

The main difference between VSTO and VSTO 2005 SE is that the latter contains application-level add-in support for Office (2003 and 2007) applications; there is no document-level customization support in VSTO

Figure 14.1. The Ribbon in PowerPoint

2005 SE (except for support for managed code behind InfoPath 2007 forms).

❖ Note You cannot simultaneously develop VSTO solutions for the 2003 and 2007 releases of Office. Side-by-side installations of these applications are not supported in a development environment.

Table 14.1 shows the differences between the VSTO features and those of VSTO 2005 SE. This table doesn't represent a comprehensive feature list for VSTO 2005 SE. However, it gives you a general idea of what you can expect from VSTO 2005 SE.

❖ Note If you've installed VSTO 2005 SE on a version of Visual Studio 2005 that doesn't contain VSTO, you will have only the functionality listed in the VSTO 2005 SE column. If you've installed it on top of VSTO, you will have the features listed in both columns.

Table 14.1. Features of VSTO

Feature

Scope

VSTO VSTO 2005 SE

Managed code extensions for Office 2003 (Word, Excel, InfoPath)

Document-Level

Actions pane for Office 2003

Document-Level

Smart tags for Office 2003

Document-Level

Document designer for data-bindable Windows Forms controls and host controls

Document-Level

InfoPath 2007 Forms

Document-Level

Add-in Support

Outlook 2003

Application-Level

✓ ✓

Outlook 2007

Application-Level

Word 2003

Application-Level

Word 2007

Application-Level

Excel 2003

Application-Level

Excel 2007

Application-Level

InfoPath 2007

Application-Level

PowerPoint 2003

Application-Level

PowerPoint 2007

Application-Level

Visio 2003

Application-Level

Visio 2007

Application-Level

Ribbon

Application-Level

Custom task pane

Application-Level

Outlook form region

Application-Level

Here's an easy way to understand which edition of VSTO to use with Office. If you want to develop solutions for Office 2003, use VSTO for document-level customizations and VSTO 2005 SE for add-ins. If you want to develop solutions for the 2007 release of Office, use VSTO 2005 SE. Note that VSTO 2005 SE does not support document-level customization for either the 2003 or the 2007 release of Office, with one exception: InfoPath 2007 Forms.

VSTO 2005 SE Add-in Model

VSTO 2005 SE provides safe loading, unloading, and management of add-ins created with managed code (Visual Basic and C#). The architecture of VSTO 2005 SE add-ins described here is identical for all the supported Office (2003 and 2007) applications but differs from add-in development of Outlook 2003 with the full version of VSTO. If you create a new project using VSTO 2005 SE, you'll see the six supported add-ins in the 2007 Add-ins node, as shown in Figure 14.2, as well as five supported add-ins in the 2003 Add-ins node.

Figure 14.2. The ThisAddin class

As with VSTO add-ins, VSTO 2005 SE add-ins provide application domain isolation for each add-in that is loaded, but a different architecture is employed in VSTO 2005 SE add-ins. When you create a new VSTO 2005 SE add-in, you'll notice that a ThisAddin (not ThisApplication) code file and class are generated. The Application object in VSTO 2005 SE add-ins is not wrapped; you will no longer find the Microsoft.Office.Tools.Outlook.Application namespace. Instead, VSTO 2005 SE add-ins reference the Interop Application object (Microsoft.Office.Interop.Outlook.Application).

So the main difference in writing code for a VSTO 2005 SE add-in is that you access the Application object through the ThisAddin class. For example, if you want to display the version of the application in a message box you no longer write

MsgBox(Me.Version.ToString())

Instead, you write

MsgBox(Me.Application.Version.ToString())

As shown in Figure 14.3, the ThisAddin class exposes a Shutdown and a Startup event and creates the event handlers, maintaining its consistency with VSTO add-ins and document-level customization projects. Even though the Application object is not wrapped, the add-in is strongly typed.

All VSTO 2005 SE add-ins follow this same pattern; however, in Excel add-ins, VSTO 2005 SE generates initialization code that wraps the Application object in the transparent proxy class, as shown in Figure 14.4. This class fixes the Excel locale issue described in Chapter 7.

Office 2007 provides a new interface for add-ins that displays specific information about the add-ins you have loaded. Any loaded shared add-in is referenced by mscoree.dll, whereas VSTO 2005 SE add-ins refer-

96 WordAddlnl Microsoft Visual Studio

B0B

File

Edit View Project Build Debug Data Tools Window

Community

Help

J

~ ~ 13 H 0 1 * 3a a 1 *) - c - m - % I ►

btbus

- Any CPU - L®

B n-j

Iii

ThisAddln.vb f File System (WordAddlnl Setup) Start Page

X

§i;l # si i m ^

a

-f (ThisAddin Events)

M*

Startup jJ

Î

Q Solution "WordAddlnl'

n

□ public class ThisAddin

-

- jj WordAddlnl i 0... jj^ word

%

n Private Sub ThisAddin Startup(ByVal s

■T

lender As

Object, ByVal e As System.EventArgs> Handles Hi

M My Project _

End Sub

&■• Gjj- WordAddlnl Setup 1=1 • S Detected Depen>

■jy

[] Private Sub ThisAddIn_Shutdown[ByVal

sender As Object, ByVal e As System.EventArgs) Handles 1

i' i* r.. J

End Sub

Solution Ex... |B}Cl»S,„-

L End class

Properties - » x

ThisAddin Startup Attribu -

Figure 14.3. The ThisAddin class for Word

Figure 14.4. The ThisAddin class

ence the path to the manifest for the add-in, as shown in Figure 14.5. This reference enables you to easily identify add-ins. What's more, only a specific add-in that causes problems need be disabled.

VSTO add-ins are loaded by AddinLoader.dll and act as a shim between the add-in and the Outlook application. Because Office 2003 shipped before VSTO, it is not aware of the AddinLoader.dll file. As described in Chapter 11, VSTO add-ins require registry entries that specify the

Figure 14.5. Add-in interface

ManifestLocation and the ManifestName. With VSTO 2005 SE add-ins, on the other hand, these registry keys are combined into one entry named Manifest. Also, the COM-specific registration is now omitted. There is no ProgId or CLSID registration under HKEY_CLASSES_ROOT, resulting in faster startup time for VSTO 2005 SE add-ins.

VSTO 2005 SE adds a new bootstrapper component, VSTOEE.dll, to the VSTO runtime. When Office sees the Manifest entry in the registry, it loads VSTOEE.dll, which then loads the proper version of the Addin-Loader.dll to load the add-in. The location of the add-in assembly is then listed in the new Add-in interface of Office 2007.

Because detailed information about the add-in is known, Office can limit hard-disabling to a specific, badly behaving add-in rather than disable the entire VSTO loader and thereby add all VSTO add-ins to the Exclusion list. As a result, VSTO 2005 SE add-ins are much more stable than VSTO add-ins or managed shared add-ins.

Figure 14.6 shows an example of a disabled add-in. In VSTO add-ins for Outlook 2003, an add-in can be disabled whenever an error occurs during startup. With VSTO 2005 SE, errors that occur in startup do not disable the add-in because the event sequencing in VSTO 2005 SE is different from that in VSTO add-ins.

Poputar

' ¿g View and manage Offke add-ins,

Formulai

Pr&ûflrtS

AAHra

Si¥é

Name

location

JTvp*

Aarane* <1

nctivr- ApptKalnn Add int

E»«i Visual stuü.Q Design Tim+ Adaptor Ajja.fi

COM Add-in

CurtMttx

EwelAflWinS

Ci\,„\E*telAddln3.dll.manrft rt

COM Atfd-in

Add-lili

j UkM'tive A|ipHC-Mion Add-in»

An*Vm ToolPafc

analyiBijJI

Excel AddUIn

"Must £ enter

Analysis îoolfrafc - VfiA

■sûp'.toaenjrfaTï

Éïctl AddUn

ComtlhaoïWl Su» Wl»rd

fij-iif j.larri

Éxctl Add-in

Rejourcei

Curto« XMl Dit)

DoewaïJit Inipeetor

[¡Mi iifflsft tag Ibtufc

DiUieflSmart TasWOfi.DU

Smart Tag

Euro Currency TcOli

eur&tddljfaitt

Excel Ad4-In

Financial Symbol ilmart tag llsb|

D^_.«<I\Smart FagWOf l.Oll

Smart. Ta g

Head« 1 arid Footers

ßUMffKiWSti&.iu

Oflçuenent inspcçtçr

Kidfltn Row? and Column;

PfU-rtiWlCilftOffRMDOU

HwWenWorkJhMfa

DiUrtGffiWiÄOfff WHD.DLl

Doiuafrà Injpertor

frit c in e t Aj m vi* rtt VBA

E*«IAd(fcin

lnvuiMe Cûrtttrtt

Document Inipertor

Lookup Vnïi-ard

fookupjdam

Excel Add-iri

M«ro5oft: AiConj Pa««

XML i>"pani5iç>ni Pack

Ptrion Niove JOtflJOOk t-m»ll rtclpltntj]

DkJWSUHrt Tig\FN*ME,Ml

Smart tig

Solw*i Adö-In

toKirjdaro

EsiMl Addhin

Telephone Number ¡Smart tag lim)

D^jwfVSmart TasfcMOf LDtl

Smart Tag

Tipne iL-mart lag lirti]

D^.«d\Srftart TagW.Ofl.DlL

Smart Tà g

rjocumenA KçUled Add litt

WOOftfWifflrifllW'AAi-fiW

! ApfihfUor AdtMiH

ÉweiAfldmS

C -■.eelAddinï.iîll.manrft Ft

CÛMAdd-in

Add-in: Active Application AdO-ins

Publisher;

Loettlon:

Df-KripOon:

Managt: fEsccel Adct-ins ^J Qp...

OK 1 Canal 1

Figure 14.6. Add-ins in the Exclusion list

Figure 14.6 shows two VSTO 2005 SE add-ins. ExcelAddin3 is listed under Active Application Add-ins, and ExcelAddin2 is listed under Disabled Application Add-ins. Each of these add-ins was created with VSTO 2005 SE, but only the problematic add-in has been disabled.

Because VSTO 2005 SE add-ins differ architecturally from and are more stable than VSTO add-ins, you might want to consider migrating existing VSTO add-ins for Outlook 2003 to VSTO 2005 SE add-ins.

0 0

Post a comment