I am currently working on a c# project, where I need to access Outlook. The development is being done on two different machines, one of which has office installed, and one of which doesn't. I previously asked how to compile my project against the outlook com object, and one of the comments suggested that I compiled against the office primary interop assembly, or PIA. In my downloaded Office 2007 PIA, there is an msi file, that is supposed to install a number of PIAs for the different parts of Office. My problem is that this seemingly doesn't happen. On my office-less machine, after typing
msiexec /i o2007pia.msi
at a prompt, the windows installer starts up, with a message box showing "Please wait while Windows configures Microsoft Office 2007 Primary Interop Assemblies. Gathering required information" along with a progress bar at about 33%, after which it disappears, and after which
gacutil -l microsoft.office.interop.outlook
yields no results for Office 2007 (I do get a result, which is versioned 10.0.4504.0 and is the result of an earlier installation attempt with a wrong Office version., but Office 2007 PIAs have major version 12.)
I see a couple of possible explanations, none of which I really believe in:
GAC can't handle multiple versions of the same assembly, and so won't allow me to install a newer version.
Somehow I don't fulfil the requirements. These are basically XPsp2, and .Net 1.1 or above, both of which I have. The requirements section also mentions, that the download works with office 2007, which I don't have installed, but I don't think this is a requirement. This is both because is isn't specified as a requirement, but also because Hans Passant in a comment to my original question was very sure that the PIAs could specifically be used for developing without Office being installed, so it would not make sense to have Office as a prerequisite.
So does anyone have any idea why the Office 2007 PIAs do not install correctly, or what I could do to get closer to an answer? If you need more information, please let me know. Thanks.
Primary interop assemblies in the program files directory The PIAs are automatically added to a location in the file system, outside of the global assembly cache, while you install Visual Studio.
Interop assemblies are . NET Framework assemblies that bridge between managed and unmanaged code, mapping COM object members to equivalent . NET Framework managed members. Interop assemblies created by Visual Basic . NET handle many of the details of working with COM objects, such as interoperability marshalling.
I hit this a while ago, with a similar project. The PIA redistributable will only install the PIAs if Office is already installed on the machine (which kind of makes sense, but can be annoying when it comes to deployment)
Visual Studio should install the Office PIAs into a folder under it's own install directory - for example, on my machine I have a copy of all the PIAs under:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office14
It's possible that these only get installed if you have Office on your machine at the time VS is installed, or perhaps there is an install option in the VS installer to install VSTO (Visual Studio Tools for Office).
If your problem is just related to getting a build working on the development machine that doesn't have Office, then you could try re-running the VS installer and see if you get an option to install VSTO, or try a google search and see if there is a separate VSTO download
Otherwise, I would just copy the PIAs from this folder to a similar location on the other Dev box.
for the first point, I am 100% sure that GAC has been implemented to support versioning of the same assemblies, you can build an assembly called myCode.dll and register its version 1.0 to the GAC, then you build the version 1.1 and 2.0 and add both to the GAC, even if all of them have the same file name, GAC will keep both and every application will be able to use the proper version depending on the assembly binding information available, basically every application which holds a reference to the version 1.0 still gets it unless specified and is not affected by the presence of newer version.
Eventually when you list the presence of the Outlook PIA in the gac you see only the latest available version and not all of them but surely you should be able, somehow, to push another version in the GAC anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With