Introduction
If you want to know how to compile and debug VSTO SE Outlook 2003 Addin on a computer with the configuration: Vista+Office 2007, read this article.
Steps
Install Office 2003 PIA and Office 2007 PIA on the same computer
- Install Office 2003 in trial mode
- Install Office 2003 PIA (we need 1. to install 2003 PIA)
- Uninstall Office 2003
- Install Office 2007
- Create 2003 Addin in Visual Studio project
Change 2003 COM reference to 2003 PIA in .csproj for "none error" compilation
- Open project file in text editor and find this fragment:
<ItemGroup>
<COMReference Include="Microsoft.Office.Core">
<Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>3</VersionMinor>
<WrapperTool>primary</WrapperTool>
</COMReference>
<COMReference Include="Outlook">
<Guid>{00062FFF-0000-0000-C000-000000000046}</Guid>
<VersionMajor>9</VersionMajor>
<VersionMinor>2</VersionMinor>
<WrapperTool>primary</WrapperTool>
</COMReference>
<COMReference Include="stdole">
<Guid>{00020430-0000-0000-C000-000000000046}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
- Replace found fragment with:
<ItemGroup>
<Reference Include="Microsoft.Office.Interop.Outloo<wbr />k,
Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" />
<Reference Include="Office, Version=11.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<Reference Include="stdole, Version=7.0.3300.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
- Save and now we have a 2003 Addin, which may be compiled under Vista+2007 Office and may be run under 2003 Office.
Note: Be careful, "do not" set <SpecificVersion>False</SpecificVersion>
for Office and Outlook DLL, because if you do it, your Addin will not run under 2003 Office.
Turn on Debug Capability
- Now, all is fine, but you can't debug 2003 Addin under 2007 Office. So for debug capability, in the project file, you need to change code which is in the tag
<ProjectExtensions>
with fragment code from Outlook 2007 Addin project.
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
<ProjectProperties HostName="Outlook"
HostPackage="{D53BAEDE-5B63-42BE-8267-3DED11EDC582}"
ApplicationType="Outlook" Language="cs" TemplatesPath=""
DebugInfoExeName=
"#Software\Microsoft\Office\12.0\Outlook\InstallRoot\Path#Outlook.exe"
AddItemTemplatesGuid="{147FB6A7-F239-4523-AE65-B6A4E49B361F}" />
<Host Name="Outlook"
GeneratedCodeNamespace="OutlookAddIn3" IconIndex="0">
<HostItem Name="ThisAddIn" Code="ThisAddIn.cs"
CanonicalName="ThisAddIn" CanActivate="false"
IconIndex="1" Blueprint="ThisAddIn.Designer.xml"
GeneratedCode="ThisAddIn.Designer.cs" />
</Host>
<ProjectClient>
<VSTO_CompatibleProducts ErrorProduct=
"This project requires Microsoft Office Outlook 2007,
but this application is not installed."
ErrorPIA="This project references the primary interop assembly
for Microsoft Office Outlook 2007, but this primary interop
assembly is not installed.">
<Product Code="{XX12XXXX-XXXX-XXXX-X000-X000000FF1CE}"
Feature="OUTLOOKFiles" PIAFeature="Outlook_PIA" />
</VSTO_CompatibleProducts>
</ProjectClient>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>