0

I wrote a .NET add-in that reference office interop assemblies with version 12 (office 2007). When I load the add-in on machines with interops with version 14, office loads this version successfully (it redirects to office 14).

BUT (and here comes the problem), on some machines it still requires version 12 although version 14 exists. Placing version 12 fixes the problem on these machines, but why does it happen???

John Saunders
  • 160,644
  • 26
  • 247
  • 397
TCS
  • 5,790
  • 5
  • 54
  • 86
  • Have you considered the 'Embed Interop Types' option for the COM interop assembly references? That should resolve your problem. – Govert May 03 '15 at 22:59
  • 1
    I'm surprised that someone with 2k rep doesn't know not to use "thanks in advance". In fact, I see that you do this on all of your questions. – John Saunders May 03 '15 at 23:01
  • 2
    Please see "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders May 03 '15 at 23:07
  • The PIAs for 12 and 14 have different version numbers. There is no "redirects". You just got lucky that most machines already had the v12 pia, ran out of luck when they didn't. Yes, always use the Embed Interop Types feature, aka the "no pia" feature. – Hans Passant May 03 '15 at 23:27
  • @Govret - that .NET 3.5, can't embed.... – TCS May 04 '15 at 02:06
  • @JohnSaunders - Your right! Fixed it. I guess the hour takes its toll. – TCS May 04 '15 at 02:08
  • @HansPassant - I am using .net 3.5 so I can't embed and the other working machines don't have office 12 interops. I have checked and rechecked. – TCS May 04 '15 at 02:10
  • You must be replying to the wrong person, since you put your "Thanks in advance" back. Did you read http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts? – John Saunders May 04 '15 at 02:10
  • Notice I am not asking how to solve the problem but rather why it happens... – TCS May 04 '15 at 02:11
  • I think you're looking for this, buddy : http://stackoverflow.com/questions/4627829/getting-started-with-visual-studio-2010-extensibility-3-questions – Jaime Reynoso May 04 '15 at 05:21
  • @user3067848 - no, its not. – TCS May 04 '15 at 07:45

1 Answers1

0

Make sure that you don't use methds and properties introduced in later Office versions (2010 and later). Thus, you will be sure that your add-in will not fire exceptions at runtime.

The Running Solutions in Different Versions of Microsoft Office page states the following:

Solutions that were created by using Visual Studio 2013, Visual Studio 2012 or Visual Studio 2010 can run in Office 2013, Office 2010, or the 2007 Microsoft Office system. However, the solution can use only those features and APIs that are available in all three versions of Office.

BUT (and here comes the problem), on some machines it still requires version 12 although version 14 exists. Placing version 12 fixes the problem on these machines, but why does it happen???

The add-in shouldn't depend on the PIAs installed. You just need to include the required PIAs into the installer and use APIs available in the lowest Office version. That's all.

Community
  • 1
  • 1
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45