Vsto learning materials: Why is vs development not supported with multiple versions of office?

Source: Internet
Author: User

Below materia is from Andrew Whitechapel's blog, which is for Visual Studio, office and other nonsense.

Origin URL: http://blogs.msdn.com/andreww/archive/2007/06/08/why-is-vs-development-not-supported-with-multiple-versions-of-office.aspx

 

Office 2007 PIAs. Either way, you'll get the last registered PIAs. So what happens if you go ahead and build this project and try to run it? As before, if you explicitly run Excel 2007, everything loads and works just fine. As before, if you try to run Excel 2003, it runs with the Excel 2007 PIAs.

So, if you really insist on having multiple versions of the PIAs on the box (and I can't think of a good reason, and we certainly don't support this scenario ), then you can workaround the problem by simply adding a reference to the specific pia you want by its path not by its COM registration. note, if you do this, you should not use the path to the Pia in the GAC. instead, you shocould copy the relevant PIAs to some known location and reference them there. so, let's say we go back to our Excel 2003 project, and change the PIA references in this way. we cocould explicitly set references to the (path to the) Excel 2003 and Office 2003 PIAs. this will build OK, and you'll end up with an assembly whose metadata specifies that it shoshould use the 2003 PIAs. if you then deploy this to an end-user machine which only has 2003, you're good. however, if you try to run it on your Dev box, it will again use the 2007 PIAs-because that's the version that was registered last. so, fixing the PIA references only ensures you build the correct assembly that will work on the end-user's machine which has the matching version of the host app. it does not help you on the dev box. if you have multiple versions on the dev box, all bets are off.

Also consider that a machine with multiple Office versions cocould have all kinds of bizarre permutations. what if you install 2003 then install 2007 then uninstall the 2007 PIAs but not the 2007 Apps; or you re-install the 2003 PIAs after installing the 2007 apps, etc, etc. or, you cocould register say Excel 2003, plus say the 2007 version of the main office DLL, plus Excel 2007 PIAs, plus the 2003 version of the main office PIAs, and so on. you can see how this rapidly produces a meaningless Dev environment-you 'd never be sure which permutation of versions you're re running against, and most permutations wocould simply not be valid in a real end-user environment. you might think you can be careful to ensure you don't end up with such silly registration permutations, but factor in that both Office 2003 and Office 2007 and their merge sub-components will auto-repair themselves at arbitrary times, and that related patches may also be applied at arbitrary times (perhaps pushed down by using ate it), and so on. you can begin to understand why we do not support this scenario.

Now consider doc-level mizmizations. this is even more interesting, because we host Excel and Word objects within the vs ide as design surfaces, using OLE inplace activation. this, of course, relies on com registration. so, on our imaginary multi-version Dev box, if you try to create an Excel 2003 doc-level mizmization, we'll end up hosting Excel 2007, and the PIA references will again be set to 2007 versions. so, for one thing, all the intelliisense and autocomplete support will be specific to the 2007 versions of the OMS. this will inevitably encourage you to use method parameters or whole features of Excel/office that are not available in the 2003 version-because the design-time support considers this valid, and the solution will build correctly (against the 2007 PIAs ).

If you go ahead anyway, and then try to run the solution, by default Vs will launch Excel 2003 (because that was the target version you specified when you created the project ), and it will load your mizmization, but with the Excel and Office 2007 PIAs. now, your code will fail in arbitrary places because you're using features that are simply not present-or are present with different signatures or semantics-in the running version. plus, of course, running an app with a later version of the PIAs is strictly not supported.

You can see that there are running good reasons why we do not support developing on a machine with multiple versions of office. you can also make the case that this is not a sensible Dev environment, it is extremely difficult to get consistent behavior, it is likely impossible to guarantee that the Environment stays consistent for any length of time, and you're pretty much guaranteed to have a Dev environment that cannot match any sensible end-user environment, which therefore invalidates any testing you might do.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.