Click here to Skip to main content
Click here to Skip to main content
Go to top

Solutions to Common Issues encountered during Outlook Add-in development.

, 1 Dec 2006
Rate this:
Please Sign up or sign in to vote.
Discusses solutions to some of the common issues encountered during Outlook Add-In development.

Introduction

In this article I intend to share some of the common issues encountered during Outlook Add-in (VSTO) development and how these may be addressed. There is interesting information available out there on the web that would help out the VSTO community and I have also tried to provide the links to these articles.

Common Issues

Is there a simpler way to add Prerequisites for VSTO through VS2005?

In an earlier article Walkthrough - Automatic Update Process for Outlook Add-in Solutions, I had discussed setting up the prerequisites through the Launch Conditions Editor. This may be a time-consuming process and may have to be repeated for other VSTO projects.

I found some interesting information here on how you can achieve it by selecting the VSTO pre-requisites directly in your Setup project. You only have to do it once and it makes life easier.

Read the instructions in file 'InstallNotes.txt' that is included as part of this download on how to set it up on your development machine. Once installed, in VS2005 you have to right click the 'VSTO Setup' project and selected 'Properties'. Click on the 'Prerequisites' button that would pop-up something similar to the screen shot shown below.

Prerequisites for VSTO

Click here to download Visual Studio Tools for Office runtime (vstor.exe).
Click here to download Office 2003 Primary Interop Assemblies (PIA) redistributable (O2003PIA.exe).

How do I Sign an Assembly prior to deployment in VS2005?

Your VSTO application needs to be signed with a strong name prior to deployment. To sign the assembly in VS2005, follow these steps:

  • Right-click your VSTO project and under Properties, select the Signing option.
  • Choose New and provide the key file name accordingly.
  • Uncheck the box that protects the key file with a password.

    Signing Assembly

How do I manually setup code access security (CAS) policy?

Once you have the .msi file generated from your VSTO Setup project, you are all set to install your solution. But you still need to consider what permissions your application requires on the end user machine and this is where CAS policy comes in.

For more information of setting up CAS at the User, Machine and Enterprise levels, refer to the article in this link.

To set up CAS for your application at the "User level", follow these steps:

  • Open Control Panel -> Administrative Tools.
  • Click on Microsoft .NET Framework 2.0 Configuration.
  • Open up Runtime Security Policy node.
  • Open the User policy node.
  • Open the Code Groups folder.
  • Right-Click All_Code group and click New.
  • Enter the Name and Description of your new code group as show below and click Next.

    Create CAS Group

  • Select Strong Name as the appropriate membership condition from the drop down and click on the Import button to retrieve the strong name from the assembly from the location the application was installed.
  • Do not set the Version of the assembly and click Next.
    Note: The procedure to "Sign an Assembly" has been discussed earlier in this article.

    Import public key

  • Select Full Trust as the permission set to your code group.

    CAS permission

    Note: This needs to be handled as part of the installation whereby you need to accomplish the equivalent of running Caspol.exe with no user intervention. Something close to this objective is discussed in the following section.

How do I programmatically configure CAS as part of Installation?

I found a sample code (available in both C# and VB.NET) published here, which may be used to handle CAS programmatically. The author has excellently handled both Install and UnInstall in his code.

Follow these steps:

  • In your VS2005 Solution, add a new Class Library project.
  • Delete the default Class1.cs file created.
  • Add a new Installer Class (SetSecurity.cs)

    Add installer

  • Cut/paste the relevant code from sample into SetSecurity.cs that you just created.
    Note: You will have to include the following 3 namespaces in the SetSecurity.cs class (which were missing)
    using System.Security;
    using System.Security.Policy;
    using System.Security.Permissions;
    
  • Configure the PolicyLevel and PermissionSet in the code to your needs.
    private readonly string installPolicyLevel = "Machine";
    private readonly string namedPermissionSet = "FullTrust";
    
  • In the Outlook Setup project, the Primary output from SetSecurity project needs to be included and using the Custom Actions Editor you may add it as a Custom Action for Install and UnInstall as shown below.

    Custom Editor for Security

  • Build the Outlook Setup project (which references both your security project and Outlook Add-in project) and Install them on the End-User machine. A snapshot of the Code Access Security (CAS) entry in the .NET Framework 2.0 Configuration is shown below.

    Result CAS

Why is the URL to the deployment server missing in the Manifest file?

A concern normally raised by the user community is that the Manifest file on the .msi installed machine does not have any reference to the published URL. There is a roundabout way to handle this.

Follow these steps:

  • In the screen-shot below, the next version of the release during a Publish in the below Outlook Add-in project would be 2.0.0.8.

    Publish version

  • Right-Click the Outlook Add-in project and do a Publish to some deployment server. Refresh the project and look for a manifest file inside the bin\Release\xxx.publish\xxx_2.0.0.8 folder (where 'xxx' is your Outlook Add-in project name).
  • Open up the manifest file and you would notice that "codebase" has the "complete URL" to the deployment server. This is the one that finally needs to show up in the end user machine.

    Manifest in Bin folder

  • Notice that the setup project shown below has the Primary output from both MyOutlookAddin and SetSecurity projects. We need to exclude the manifest file from the primary output of the Outlook Add-in.
  • Right-click on the Primary Output from Outlook Add-in and select Exclude Filter.

    Exclude Filter

  • Click on Add Filter to exclude the manifest file shown in the primary output.

    Exclude Filter result

  • You now have to manually add the right manifest from the bin folder that was published. Right click on the Setup project and select Add followed by File.

    Add Setup file

  • Navigate to bin\Release\xxx.publish\xxx_2.0.0.8 folder and select the recently published manifest and add it to the project. Open the manifest file to confirm that the URL to the published server exists in the manifest as shown below.

    File Add result

  • Rebuild your setup solution and install it on the end user machine.

Conclusion

The objective of writing this article was to share the information I gathered from both experience and reading what the experts out there had to say, so as to provide a helping hand to the VSTO community.

This way of setting up CAS is good enough for the application to run on one machine. Unfortunately, we cannot expect all end-users to manually set up the CAS for your Outlook Add-in assembly.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Sanjeev Thazhathaveetil

United States United States
No Biography provided

Comments and Discussions

 
Questiondo you know of any outlook ad-on developers? PinmemberMember 788177828-Apr-11 13:04 
QuestionAddIn fails to load with manually added (published) manifest PinmemberKlemens Kanal14-Aug-07 2:37 
QuestionHow to get body of new arrived email. PinmemberShashi Shinde1-Mar-07 18:30 
QuestionStep 5: Fails to update local copy from deploy location PinmemberDenis bda22-Feb-07 5:10 
AnswerRe: Step 5: Fails to update local copy from deploy location PinmemberDenis bda28-Feb-07 3:09 
In order to get around this issue I essentially had to write my own modification of auto update functionality.
 
I read in local and remote manifests, compared them, if newer then started a sidecar app that closed the current instasnce of excel, copied the updates and started a new isntance
GeneralIf Server is OFFLINE - custom update functionality PinmemberSanjeev Thazhathaveetil10-Mar-07 3:29 
Questionstep 5 problem Pinmemberjdrawmer20-Feb-07 23:41 
AnswerRe: step 5 problem Pinmemberjalekz21-Feb-07 7:53 
AnswerRe: step 5 problem [modified] PinmemberMember 213663821-May-08 2:20 
Generalrecipients, subject, body of a Mail not recognised Pinmemberaxn3212-Feb-07 21:03 
QuestionUpdate runs from server only Pinmembercolinmc1-Feb-07 4:18 
AnswerRe: Update runs from server only PinmemberSanjeev Thazhathaveetil1-Feb-07 5:35 
GeneralRe: Update runs from server only Pinmembercolinmc5-Feb-07 23:10 
GeneralInstalling on 2K3 with terminal services Pinmemberbon73329-Jan-07 18:08 
GeneralUnable to get plug-in to update from server PinmemberJason Hills20-Dec-06 16:19 
AnswerRe: Unable to get plug-in to update from server PinmemberJason Hills21-Dec-06 14:17 
GeneralRe: Unable to get plug-in to update from server [modified] Pinmemberroyal_hale5-Feb-07 11:20 
GeneralNow this is more like it. Pinmembernorm .net1-Dec-06 22:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 1 Dec 2006
Article Copyright 2006 by Sanjeev Thazhathaveetil
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid