Dynamically accessing the most current version of an assembly

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?
 
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 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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top