views:

36

answers:

2

I'm automating some outlook functionality in a .NET app. It works great. I am compiling it and using v 12.0.0.0 of the Outlook Interop assembly.

My code should work on any version of Outlook so it seems silly to have to bind it to a specific version.

Is it possible to use reflection to do this instead of compiling a reference?

Are the interop assemblies on PC's by default that have Office installed anyway or do I need to include them with my application?

I remember with COM I used to be able to say something like CreateObject("Outlook.Application") without needing a strong reference. I'd like to try something like that here. I suppose I could just use COM without the Interop .NET assembly as a back up plan.

Any advice?

Thanks

+1  A: 

You can dist the v12 PIA with your application, and it will work with future versions.

I've done this myself.

SLaks
Think it works with prior versions? Ex: Office 2007?
Dan
+1  A: 

It is Microsoft's burden to keep the COM interfaces compatible. It is required in COM, a published interface can never change. They've done an astonishing job over the years, it must have been difficult.

But you'll have to pick some kind of version of the PIA to target and avoid using interfaces that became available in later editions. It is up to you to find out how far you want to go back, we don't know what interfaces you use. Download it from MSFT and select it in the Add Reference dialog. Office XP is the earliest, you'd have to generate your own if you want 2000.

Hans Passant
So it sounds like it's future compatable. Example PIA for Office 2003 distributed on a PC without Office 2003, but has Office 2010 will be guaranteed to work?
Dan
Also - I ended up removing the PIA reference and took the COM route. I created object instances based on class names eliminating the need for the PIA assembly. I lose the intellisense when developing and I don't notice a performance hit. If I need intellisense I can breifly reference the PIA to develop and then remove it and go back to the COM reference.
Dan
Do beware that a PIA is required when you expose your Office interop interfaces to other, separately built assemblies. That isn't very common though. And don't forget to distribute your interop DLL.
Hans Passant