R – .NET/COM Interop problem – opening Outlook 2003 Send Mail dialog


We have a WinForms app, written in VB.NET (CLR 2.0), that does a lot of Outlook-related stuff. One of the things we do is programmatically open up a new Outlook 2003 'compose new Email' form, pre-populated with the 'to' address.

Me.WordApp = New Word.Application
Dim template As Object = System.Reflection.Missing.Value
Dim newTemplate As Object = System.Reflection.Missing.Value
Dim documentType As Object = Word.WdNewDocumentType.wdNewEmailMessage
Dim visible As Object = False
Me.WordDoc = Me.WordApp.Documents.Add(template, newTemplate, documentType, visible)
'then some other stuff

Now, this works perfectly almost everywhere we deploy the application – the user fills in the email subject and text, clicks send, and we can catch the Send event and do other good stuff.

There are just a couple of installations where it breaks, and we just can't get to the bottom of it.

Does the following give any indication of where the problem might be:

Could not load file or assembly 'office, Version=, Culture=neutral, 
PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The located assembly's 
manifest definition does not match the assembly reference. (Exception from HRESULT: 

As far as we can tell, these are just Office 2003 installations, with Outlook and Word, just as in the cases where it works fine.

I'd be very grateful for any ideas – either on how to fix this, or on a better way of achieving the same thing.

Best Solution

I had a similar experience with an Excel 2003 Add-In. Do you have both Office 2003 and Office 2007 installed on the development machine? If so, check the References section in your project thouroughly. I had a dependency to Office 11, but underneath the Office 12 interop assembly was used.

I think that Assembly Binding Redirection was causing me the trouble.

Edit: Microsoft's example projects helped a lot. An additional issue were the security settings on some machines (see the SetSecurity project which is used in example setup projects).

Related Question