views:

504

answers:

2

I have Office 2007 on my dev machine. I have a small app I'm building for a customer server with Office 2003 that needs to do some interop. My program will run as a scheduled task in a nightly batch process.

No matter what I do, I can't find the version 11.0 of the Access interop assembly so that will work on the server.

I've tried explicitly downloading and installing them on my machine. I tried installing the 2007 interop assemblies on the server (a full Office 2007 install is out of the question). I tried several different COM references. I tried looking for the COM object on the server to reference in the visual studio project. And I've tried too many other little things to list them all here.

What's going on here? How can I get this working?

+1  A: 

I've found the only way to do this, even with both versions installed side-by-side, in .Net v2 and above, was to add a reference to the PIA (rather than the COM lib). Frameork v1.1 would actually bind to the correct version, if they were present side-by-side.

Rowland Shaw
I can't find the PIA file anywhere.
Joel Coehoorn
Okay: I'm an idiot. I couldn't find the file in the server's GAC, but the 2007 version (and only the 2007 version, even though I've explicitly installed the 2003 PIAs) is in my local GAC. Unfortunately, this still doesn't work on the server and it just hangs when I try to open the Access file. But that's a whole different question
Joel Coehoorn
I must admit, to get the PIAs in the first place, we extracted them from the GAC (the Office XP PIAs came in a nice ZIP which made them easier to get hold of).Not sure on the licensing implications, but could you side by side the PIA? (obviously would still need Access on there)
Rowland Shaw
Licensing should be moot: this will go to a single customer that does have Office on the machine. We can install from the msi if needed, but can't update the office version on the machine.
Joel Coehoorn
A: 

Can't you copy the PIA from the server to your machine (to a local folder) and then add a reference to that copy?

If you like to go another way you could avoid using the PIAs and use ComImport instead. Andrew Whitechapel has the details in his blog:

Add-ins for Multiple Office Versions without PIAs

Update (from comment): If you can't locate the Access PIA on the server you could try the following:

  • Download the Office 2003 PIA setup from here: Office 2003 Update: Redistributable Primary Interop Assemblies

  • Extract the self-extracting executable on the command line (/? will list the options):

    >O2003PIA.exe /C /T:C:\PIA
    
  • Run the extracted MSI with full logging enabled:

    >msiexec -i O2003PIA.msi /l*vx log.txt
    

    and check the log for the Access interop assembly and further hints whether anything went wrong with the installation. Alternatively to this step you could use an MSI unpacker utility to geth the assembly.

0xA3
No, the PIA file doesn't exist on the server anywhere, even after I downloaded and installed them manually.
Joel Coehoorn
BTW: interesting solution in the link, but if I used something like that I'd be laughed out of the room at code review time. I can see it now: "WTF is all this crap?"
Joel Coehoorn
Indeed. Looking forward to VS 2010 which will handle all the ComImports for you nicely...
0xA3