Groups | Blog | Home
all groups > dotnet interop > june 2005 >

dotnet interop : Office PIA:s. Can they be made to work properly?


KennethBohman
6/29/2005 5:05:02 AM
Hi everybody,

I mentioned some time ago that an application getting data from an Excel
spreadsheet, stopped reading the spreadsheet after the client upgraded from
Office XP to Office 2003. Well, I thought it still would do, but although
confirmed in this forum that apparently remained unknown to the application.
Still needs to be looked into!

This time a client wanted to automatically create a Word document from an
application. They are on Office 2003 and I’m developing on Office XP. Guess
what? That didn’t work either! Clearly I was doing something wrong, so I’d
better try something really simple. I :

1) Revisited the article: Working with the Office XP Primary Interop
Assemblies
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/odc_oxppias.asp
and created that project anew.

2) Downloaded the trial version of Office 2003 and registered the PIA:s.
Looks OK in the GAC.

Whatever way I try I can’t make it work even on my computer now. Description
of basic tests.
Setup as in the article above:
Console Application: OfficeXPPIATest
Setup Project: OfficeXPPIATestSetup

TEST GROUP 1: Console Application only, that is Setup Project not included
in the build

Test 1: XP PIA:s
Reference properties show:
C:\windows\assembly\GAC\Microsoft.Office.Interop.Word\10.0.4504.0…..
Result:
a) Build successful
b) Build+Run successful, but followed by the message:
<An exception ‘System.Runtime.InteropServices.COMException’ has occurred in
OfficeXPPIATest.exe. However, a debugger that cannot handle the exception
type is already attached to the process>
Comment: this message did not occur before I installed Office 2003.

2) 2003 PIA:s
Reference properties show:
C:\windows\assembly\GAC\Microsoft.Office.Interop.Word\11.0.0.0…..
Result:
a) Build successful
b) Build+Run successful, but message
An exception ‘System.Runtime.InteropServices.COMException’ has occurred in
OfficeXPPIATest.exe. However, a debugger that cannot handle the exception
type is already attached to the process

Conclusion: no difference between XP PIA:s or 2003 PIA:s


TEST GROUP 2: Console Application + Setup Project
3) XP PIA:s
Reference properties show:
C:\windows\assembly\GAC\Microsoft.Office.Interop.Word\10.0.4504.0…..
a) Build successful
b) Running the application after installation
Successful, but message
An exception ‘System.Runtime.InteropServices.COMException’ has occurred in
OfficeXPPIATest.exe.

4) 2003 PIA:s
C:\windows\assembly\GAC\Microsoft.Office.Interop.Word\11.0.0.0…..
Result:
a) Build successful, but
I) Output window
Build
------ Starting pre-build validation for project 'OfficeXPPIATestSetup'
------
WARNING: Unable to find dependency 'mscorlib' (Signature='B77A5C561934E089'
Version='1.0.5000.0') of assembly 'Microsoft.Office.Interop.Word.dll'
WARNING: Unable to find dependency 'mscorlib' (Signature='B77A5C561934E089'
Version='1.0.5000.0') of assembly 'Microsoft.Vbe.Interop.dll'
WARNING: Unable to find dependency 'mscorlib' (Signature='B77A5C561934E089'
Version='1.0.5000.0') of assembly 'Office.dll'
------ Pre-build validation for project 'OfficeXPPIATestSetup' completed
------
------ Build started: Project: OfficeXPPIATestSetup, Configuration: Debug
------
WARNING: Two or more objects have the same target location
('[targetdir]\office.dll')
WARNING: Two or more objects have the same target location
('[targetdir]\office.dll')
WARNING: Two or more objects have the same target location
('[targetdir]\microsoft.vbe.interop.dll')
WARNING: Two or more objects have the same target location
('[targetdir]\microsoft.vbe.interop.dll')

II) OfficeXPPIATestSetup references are duplicated, i.e
Detected Dependencies
Microsoft.VBE.Interop.dll:
C:\windows\assembly\GAC\Microsoft.vbe.Interop.Word\11.0.0.0…..
Microsoft.VBE.Interop.dll:
C:\windows\assembly\GAC\Microsoft.vbe.Interop.Word\10.0.4504.0…..
Office.dll: C:\windows\assembly\GAC\Office\7.0.3300.0…..
Office.dll: C:\windows\assembly\GAC\Office\11.0.0.0…..

b) Running the application after installation
See test 3

Not very successful as you can all see.

My question really is what to do? Clearly there are problems with the PIA:s,
but some of you must be writing apps on machines with multiple Office
versions or on machines running other Office versions than they were
developed on. However sad I must sound, whatever Microsoft seems to have put
into .NET is a gotcha to keep you awake at night. Not that I’m getting
nostalgic about VS 6!!!

--
Thanks for your help,

rox.scott
7/26/2005 1:49:02 PM

I found the only way to reference a version prior to the one on the build
machine is to build your own Interop assembly.
See http://www.devcity.net/Articles/163/1/article.aspx

--scott

--


[quoted text, click to view]
AddThis Social Bookmark Button