Tuesday, March 7

Deploying a Managed COM Add-in using an Outlook Shim

I have been trying to get a managed code outlook add-in to work using an "Outlook Shim", to remove a warning message about a potential security risk. This allows the add-in to be trusted without trusting all .NET managed code add-ins.

I followed the instructions in "Using the COM Add-in Shim Solution to Deploy Managed COM Add-ins in Office XP". There were a couple of small issues that I’ve recorded here in case anyone else is trying this or I need to do this again.

The Managed Code add-in needs to have a strong name. I needed to make some configuration changes to generate this. Firstly, I added the "AssemblyKeyFileAttribute" to the AssemblyInfo.cs file, like this.

[assembly: AssemblyVersion("1.0.*"), AssemblyKeyFileAttribute("..\\..\\Project.snk")]

I then found that my project referenced Microsoft.Office.Core. This is not strongly named, and this stops the managed code add-in from building. To get around this, I downloaded the Primary Interop Assemblies from here
and replaced the references with these DLLs.

Apart from this, the instructions, although long and initially very daunting, seem to work. Does this need to be this complicated? There is a very strong temptation for people to instruct their users to ignore security risks and if they do so in your application they may think it's OK to do so at other times.

No comments: