Office Interop publishing issues

coder_t2

Member
Nov 6, 2009
92
0
0
Hey guys, I developed a program to work for Excel 2003. However, anytime I publish the program and try to install it on another machine, it asks for Interop 12. The error goes something like this...

The application requires that assembly office Version 12.0.0.0 be installed in the Global Assembly Cache (GAC) first.

Now, I told Visual Studio to use Interop 11 library, but I went I look at the properties of the reference, it referencing the Interop 12 files. From what I understand, it is because the Interop 12 library was set up to also point to Interop 11 inside of it. Or something like that. I could be wrong though.

Anyhow, is there a way to tell the program to look at Interop 11, or at least install the correct Interop library onto the client machine.

I did try downloading the 2007PIA, but I was still getting the error, so I am pretty confused at this point.
 

Snapster

Diamond Member
Oct 14, 2001
3,916
0
0
Office PIA stands for pain in the ass...

I'm guessing you have Office 2007 installed and at some point you either had Office 2003 or downloaded the 2003 PIA's. Because of policy files installed in the GAC, any call to the v11 Interop is automatically being redirected to the v12 (Great idea MS!). You could try assembly redirection or create a policy file but I'm not sure that works backwards in versions.

Even if you have the Office 12 PIA's on the target machine you do need a version of office installed (2003 in this case) and they wont run or possibly install correctly. The only ways out is either downgrade your Office to 2003 or find a machine that does and compile on that or get the 2007 PIA's installed properly into the GAC (or possibly ship in \bin).
 

coder_t2

Member
Nov 6, 2009
92
0
0
What a pain in the ass. Okay, I knew the client machine would have to have Office 2003 installed. And you guessed right. My developer box had 2003, but occasionally I needed more than 65k lines, so I installed 2007 as well.

How do I do assembly redirection? I liked just using one box as a developer box. My client test machine only has Office 2003. But I suppose I could turn that into a second dev box.
 

Snapster

Diamond Member
Oct 14, 2001
3,916
0
0
You could try ignoring the publisher policy by adding to your application config:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Office.Interop.Excel"
publicKeyToken="71e9bce111e9429c"
culture="neutral" />
<publisherPolicy apply="yes" />
<bindingRedirect oldVersion="12.0.0.0"
newVersion="11.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Another way may be to copy the v11 PIA's into your project and refer to them directly
 
Last edited: