Creating a managed Smart Document project or Add-in for Office 2003 is a bit of a headache because of the many configuration problems one might encounter.

Here is a short summary of the prerequisites of such a project on a target system: 

What to install

Microsoft Office 2003 with the following features enabled:

  • Microsoft Office Excel -> .NET Programmability Support
  • Office Tools ->Microsoft Forms 2.0 .NET Programmability Support
  • Office Tools -> Smart Tag .NET Programmability

Why?

There are some DLLs in the following folder which are required for Office to be able to load managed solutions:

c:\Program Files\Microsoft Office\Office11

Explanation

Office 2003 uses the OTKLoadr.dll library to load Visual Studio customizations, smart documents and smart tags.

 

What to install

Office 2003 PIAs (Primary Interop Assemblies)

Why?

This will add the Smart Tag Library to the GAC

Explanation

Managed code that implements the ISmartDocument interface requires a reference to the Microsoft.Office.Interop.SmartTag namespace.

See: http://msdn.microsoft.com/en-us/library/aa195478(office.11).aspx

 

Download for Office 2003 PIA:

http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&displaylang=en

 

What to install

VSTOR 2005 SE

Why?

The VSTO runtime automatically installs the newest version of OTKLOADR.DLL and additionally adds the CLR Lockback registry key ([HKEY_CURRENT_USER\Software\Classes\Interface\{000C0601-0000-0000-C000-000000000046}]). This enables Office 2003 to run .NET 2.0 code, as initially Office 2003 could not do this.

Explanation

Download for VSTOR 2005 SE

http://www.microsoft.com/downloads/details.aspx?familyid=f5539a90-dc41-4792-8ef8-f4de62ff1e81&displaylang=en

Alternately, one can install the KB907417, which includes the newest version OTKLoadr, and set up the registry key manually.

 

What to install

Extensibility fix

Why?

Adds the Extensibility.dll to the GAC.

Explanation

This is included in the extensibilityMSM,msi file from KB 908002. http://support.microsoft.com/kb/908002

 

The IDTExtensibility2 interface is required for all add-ins and automation projects (it includes events like loading, unloading, updating)

http://msdn.microsoft.com/en-us/library/extensibility.idtextensibility2.aspx

 

 

What to install

.NET Framework Runtime 1.1

Why?

See the explanation for “FullTrust”

Explanation

Download:

http://www.microsoft.com/downloads/details.aspx?familyid=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en

 

What to install

.NET Framework 2.0

Why?

Obviously, the code is written in .NET 2.0 and requires the framework

Explanation

Download:

http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=en

 

What to install

The installed DLL should be added to the “FullTrust” zone for both .NET 1.1 and .NET 2.0

Why?

Automation code that is executed via the OTKLoadr appears to follow the permission guidelines of .NET 1.1. However, as the solution most likely contains code whose call stack go through the  .NET 2.0 Framework (e.g. a simple MessageBox.Show()) , the code needs to be trusted also by the .NET 2.0 Framework

Explanation

Add the DLL to the Full Trust zone using the CASPol tool from the .NET Framework:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\ and

C:\Windows\Microsoft.NET\Framework\v1.1.4322\

CASPol.exe –ag My_Computer_Zone –url “C:\Users\[Username\Local Settings\Application Data\Microsoft\Schemas\[NameSpace]\[Name].DLL” FullTrust

 

Here is a sample Visual Studio 2008 project which creates a very basic Smart Document DLL in .NET 2.0. It also contains the manifest and a sample schema:

SmartDocument.ZIP