Dynamically accessing the most current version of an assembly

  • Thread starter Thread starter zumbo
  • Start date Start date
Z

zumbo

I'm accessing MSOutlook via Microsoft.Office.Interop.Outlook. It works
fine if I add a reference to either version 11 (Outlook 2003) or
version 12 (Outlook 2007) of the interop assembly to my project.
However, I don't want to build two different applications for each
version; I want my application to detect and use the current version
at runtime. But when I load the assembly at runtime, I don't have
access to its classes at compile time and I have to access everything
through reflection. Isn't there an easyer way?
 
I'm accessing MSOutlook via Microsoft.Office.Interop.Outlook. It works
fine if I add a reference to either version 11 (Outlook 2003) or
version 12 (Outlook 2007) of the interop assembly to my project.
However, I don't want to build two different applications for each
version; I want my application to detect and use the current version
at runtime. But when I load the assembly at runtime, I don't have
access to its classes at compile time and I have to access everything
through reflection. Isn't there an easyer way?

I just figured it out myself. In my project, I have to add a reference
to the older version, but it turns out that this will work out fine
when only the newer version is present at runtime.
I can work directly with everything from the old interface, and I can
load the new version (if present) dynamically, and access the classes
that aren't present in the old version using reflection. (Which isn't
half as bad as accessing everything through reflection).
 
Back
Top