Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / July 2007

Tip: Looking for answers? Try searching our database.

Excel 2003 + 2007 on dev machine - deployment problems on Excel 2003 machine

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Hearn - 02 May 2007 12:42 GMT
I'm writing a C# app which will populate an Excel spreadsheet.  The app
references Excel using COM.

I have Office 2007 on my machine, but the machine which will be running
the application will have Office 2003.  Therefore, when I added the
Excel COM reference, I chose the Excel 11 one.

Now that I'm trying the application on another machine I'm getting
errors saying that the Microsoft.Office.Interop.Excel version 12.0.0.0
is missing.  Viewing the object browser I see that
Microsoft.Office.Interop.Excel is described as:

Assembly Microsoft.Office.Interop.Excel
C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll

This is strange condisering in the Solution Explorer view, I see the
properties for the Excel Reference set to:
Microsoft.Office.Interop.Excel
Microsoft Excel 11.0 Object Library
C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll

It's saying it's Excel 11, but then references the Excel 12 interop
libraries.  I've removed the reference and added it again and it's still
the same.

Any suggestions as to how I fix this?  I need to keep Office 2007 on
this machine, but need to be able to build for Excel 2003.

Thanks

David
Bill F - 02 May 2007 14:28 GMT
I had the same issue.  After some research and testing, I discovered that
one cannot develop a .Net application for Excel on a development machine
that has Office 2007 and have this application work on a computer that has
Office 2003.  However, your development machine can have Office 2003 and
your application will work on machines with Office 2003 or Office 2007.
Consequently, I had to go back to a development machine with Office 2003.

CAUTION:  as you will see in my post that follows this message, when I
uninstalled Office 2007 from my development machine and installed office
2003, I had big problems getting the application .exe to work.  I'm still
trying to resolve this.

Bill

> I'm writing a C# app which will populate an Excel spreadsheet.  The app
> references Excel using COM.
[quoted text clipped - 27 lines]
>
> David
David Hearn - 02 May 2007 16:34 GMT
From what I've been able to deduce, Office 2007 has redirects from
Office 11 PIAs to Office 12 PIAs because they 12/2007 ones are backward
compatible to 11/2003.

This means that whenever I add a reference to the Office 2003 Interop, I
actually (without warning) get redirected to the Office 2007 Iterop files.

This causes a problem as when you build it, it references the Office
2007 ones, and deploying onto a Office 2003 machine - it doesn't have
the Office 2007 ones.

Everything would be fine if my dev machine was Office 2003 and the
depoyment machines were 2003 or 2007.

The solution it seems is in your app.config file redirect the request
for v12 ones to v11.

<?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>

It's working for me with that as the main app.config file.  The actual
app doesn't use the Excel part, but a DLL it references does, and it
seems that it's only the main app which needs this, not the DLL.

I'm also not sure whether this is a recommended way of doing it - but as
I said, works for me.

Hope that helps you.

David

> I had the same issue.  After some research and testing, I discovered
> that one cannot develop a .Net application for Excel on a development
[quoted text clipped - 42 lines]
>>
>> David
Bill F - 03 May 2007 00:13 GMT
David:

So, let me see if I got this right.  You build your application on a machine
with Office 2007 installed.  When you deploy the application to a machine
with Office 2003, you include the app.config file you desribed below.  When
you deploy your application to a machine with Office 2007, you don't include
the app.config because the redirect is not needed.  Is this correct?

Getting Closer Bill
(maybe)

> From what I've been able to deduce, Office 2007 has redirects from Office
> 11 PIAs to Office 12 PIAs because they 12/2007 ones are backward
[quoted text clipped - 86 lines]
>>>
>>> David
David Hearn - 03 May 2007 09:23 GMT
Correct, that's what I've done.  When I try it on my dev machine (with
the app.config and Office 2007 and Excel 2003 present) it works in just
the same way it seems - so I'm not 100% sure if you need to worry about
not deploying it to Office 2007 machines.

In my source folder and project I have an app.config file, when I build
it, it creates a <executablename.exe>.config file in the bin\Release and
bin\Debug folders containing the same information.  It's that file (not
the one called app.config) that I'm deploying.

Hope that helps,

David

> David:
>
[quoted text clipped - 99 lines]
>>>>
>>>> David
Bill F - 03 May 2007 14:46 GMT
David:

This could be the answer to my woes.

I am curious...how is it that you have Office 2007 AND Excel 2003 installed
on the same computer?  I didn't think that was possible.  Are both versions
of Interop.Excel on your development computer, i.e. Version 11.0 and 12.0?

If I go back the system with Office 2007 installed (I saved an image before
uninstalling Office 2007), I wonder if I can install Interop.Excel version
11.0 using the Office 2003 PIA installation O2003PIA.msi I downloaded from
Micrsoft.

Bill

> Correct, that's what I've done.  When I try it on my dev machine (with the
> app.config and Office 2007 and Excel 2003 present) it works in just the
[quoted text clipped - 113 lines]
>>>>>
>>>>> David
David Hearn - 03 May 2007 15:47 GMT
What I did was have Office 2003 installed and upgraded (ie ran Office
2007 installer).  This removed Office 2003.

I then started developing my application (actually part of a larger
application), and realised when I came to the Excel part that most
people (including the other developers building bits for this app) would
 be using Office 2003.  At this point I installed Excel 2003 (as part
of an Office 2003 install where I only installed Excel) alongside my
Office 2007 install.  No problems at all (except I've since noticed that
the .xls files are registered to Excel 2003 now - but that's a minor thing).

Yes, both versions of the Excel PIAs are present - however, Excel 2007
(and all Office 2007 apps) installs with the PIAs some redirect
assemblies which mean that when an application requests an Excel 11 PIA,
they're redirected to Excel 12.

When I added a COM reference, I selected Excel 11.  However, I noticed
yesterday that actually the file this refers to in the Properties view
of this reference is the 12 version.  Hence anything I build will
require Excel 12 installed.

Ideally the redirect I posted should be done in VS2005 (actually,
ideally it VS2005 should by default ignore the redirect) as if you have
explictitly requested Office 11 COM objects it shouldn't then use Office
12 ones.  If it was done this way, then the application would be build
for Office 2003, but when run on an Office 2007 machine, would work fine
as the MS redirect assemblies would do their job.

The other solution that Walter Wang from MS suggested is to remove the
Office 2007 PIAs from my machine, and only have the 2003 ones installed.
 At the moment, I have no need to specifically develop for Office 2007
apps, so this might be the best option, although I'm glad I found a work
around.

Hope that helps,

David

> David:
>
[quoted text clipped - 129 lines]
>>>>>>
>>>>>> David
Walter Wang [MSFT] - 04 May 2007 06:52 GMT
Hi David,

Looks like only applications compiled against Office 2003 PIA can run on
system with Office 2007 installed, applications compiled against Office XP
PIA will not be able to run on system with Office 2003 or 2007:

#ArtLeo's WebLog : Office System 2007 PIA Compatibility
http://blogs.msdn.com/artleo/archive/2006/03/24/560418.aspx

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
David Hearn - 04 May 2007 08:33 GMT
Correct - Office 2003 and 2007 are special cases.  Prior to 2007, you
could only target a single specific version of Office, and if you needed
to support multiple versions you needed a separate binary for each.

With Office 2007 Microsoft made it backwards compatible and added the
redirection assemblies so that Office 2003 apps would run on Office 2007
without any recompiles or changes.  However, its these redirection
assemblies which are confusing VS2005 into compiling against Office 2007
PIAs rather than Office 2003.

Thanks for your help though,

David

> Hi David,
>
[quoted text clipped - 15 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Bill F - 03 May 2007 14:46 GMT
David:

This could be the answer to my woes.

I am curious...how is it that you have Office 2007 AND Excel 2003 installed
on the same computer?  I didn't think that was possible.  Are both versions
of Interop.Excel on your development computer, i.e. Version 11.0 and 12.0?

If I go back the system with Office 2007 installed (I saved an image before
uninstalling Office 2007), I wonder if I can install Interop.Excel version
11.0 using the Office 2003 PIA installation O2003PIA.msi I downloaded from
Micrsoft.

Bill

> Correct, that's what I've done.  When I try it on my dev machine (with the
> app.config and Office 2007 and Excel 2003 present) it works in just the
[quoted text clipped - 113 lines]
>>>>>
>>>>> David
Walter Wang [MSFT] - 03 May 2007 07:29 GMT
Hi David,

Looks like you've installed Office 2007's PIA (Primary Interop Assembly).
In VS2005, when you add a COM reference, it will try to check first if
there's any PIA registered for that COM component, if found, it will use
that PIA from GAC.

Please uninstall Office 2007's PIA and install Office 2003 PIA from here:

http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-
8ba0-d36d67e0f4ad&displaylang=en

For more information about PIA:

http://msdn2.microsoft.com/en-us/library/aa302338.aspx

Hope this helps.

Sincerely,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
MissPing - 03 May 2007 08:54 GMT
Hi

I am so sorry for posting here, but I am unable to post a new question for
some reason. Please, please, please can you help me? I need to create a
trendline on my graph, and it is not letting me do it. Please help me, so
much rests on this!

Thank you so much in advance.

> Hi David,
>
[quoted text clipped - 39 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
David Hearn - 03 May 2007 09:33 GMT
I had Office 2003 installed, and when I got Office 2007 I just did an
upgrade, so don't think I got to pick what got installed or not.

What I've gathered is that previously with Office 2003 and before the
PIAs weren't installed as default, causing issues with deployment of
apps which rely on them.  In Office 2007 Microsoft have changed it so
that the PIAs get installed as default (which I guess happened here).

How should I uninstall the Office 2007 PIAs?  Are they the the ".NET
Programmability Support" which is a per-application option which
describes itself as "Primary interop assembly that allows Microsoft
Office <product> programmability with .NET Framework version 1.1 or
greater".

Do I also need to remove the one called "Microsoft Forms 2.0 .NET
Programmability Support" which is a PIA for MS Forms 2.0?

Thanks

David

> Hi David,
>
[quoted text clipped - 39 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Bill Fallon - 03 May 2007 22:32 GMT
Walter:

I followed your suggestion below:  I uninstalled the Office 2007 PIAs by
running the Office installation program and making sure each .Net Program
Support item was set to Not available.  I checked the GAC and saw that all
the Office.Interop assemblies are gone excep Access.dao.  Then I tried to
install the redistributable Office 2003 PIAs by running O2003PIA.msi that I
downloaded from the link you provided:

http://www.microsoft.com/downloads/thankyou.aspx?familyId=3c9a983a-ac14-4125-8ba
0-d36d67e0f4ad&displayLang=en


When I do this, I get the message "Please install Microsoft Office 2003
before installing this product.  So this PIA installation program will not
let me install the Office 2003 PIAs while I have Office 2007 installed.

How do I install the Office 2003 PIAs when Office 2007 is already installed?

Bill

So how do I install the
> Hi David,
>
[quoted text clipped - 41 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
David Hearn - 04 May 2007 08:35 GMT
Did you have Office 2003 (or any part of it) installed at the time of
installing the PIAs?  You do need one of the apps installed before you
can install the PIAs.

D

> Walter:
>
[quoted text clipped - 67 lines]
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
Bill Fallon - 04 May 2007 15:06 GMT
No, there is no part of Office 2003 installed, only Office 2007.  However, I
did find a solution.

This solves the problem of developing .Net application that uses the office
interops (PIAs) on a development computer having Office 2007 installed,
where the application works on a client computer with either Office 2003 or
Office 2007.

The solution is:

1.  Make sure the Office 2007 PIAs are not installed on the development
computer.  Do this by going to the Office 2007 setup program and setting the
.Net Programmabilty support to Not Available for each Office component.

2.  Copy Office 2003 Interops to a directory on the development computer
with Office 2007, say D:\Dev\NetRedist.  Note: running the Office Interop
redistributables installation program o2003PIA.msi downloaded from

http://www.microsoft.com/downloads/thankyou.aspx?familyId=3c9a983a-ac14-4125-8ba
0-d36d67e0f4ad&displayLang=en


requires that Office 2003 be installed, so it won't work because Office 2007
is installed.  So, go to a development machine with Office 2003 installed.
From a .Net project add a reference to the desired Office 2003 interop, e.g.
Microsoft.Office.Interop.Excel version 11 (use the Com tab and selection
Microsoft Excel 11 Object Library).  In the properties for this reference
set Copy Local to true.  This places Microsoft.Office.Interop.Excel in the
bin\debug directory.  Copy this file to D:\Dev\NetRedist on the development
machine with Office 2007.

3.  In the Office 2007 development computer, add a reference to the interop
by selecting the browse tab and navigating to D:\FMI\Dev\NetRedist.

4.  Select Copy Local to True in the reference properties to put a copy of
the Interop in the bin\debug directory.

5.  Include the interop with the application assembly in the application
setup program.  Make sure the application assembly and interop are in the
same directory on the client computer.

This approach does not require a config file with a redirect.  I've tested
it and it works.

Bill

> Did you have Office 2003 (or any part of it) installed at the time of
> installing the PIAs?  You do need one of the apps installed before you can
[quoted text clipped - 77 lines]
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
Stephen - 31 Jul 2007 14:14 GMT
See the following post:

Wrong Interop Version of Excel loads

http://msdn.microsoft.com/newsgroups/default.aspx?&guid=&sloc=en-us&dg=microsoft
.public.dotnet.framework.interop&p=1&tid=257774b4-18d4-4f24-b413-29cabdc46dc4&mi
d=a1828149-8b1c-401a-ab51-11c7e5ce3524


I think there's a simple answer that still allows you to keep both versions
of Excel on the Dev machine.

Signature

Stephen
there are 10 types of people in the world, those that understand binary and
those that don''t

> Did you have Office 2003 (or any part of it) installed at the time of
> installing the PIAs?  You do need one of the apps installed before you
[quoted text clipped - 73 lines]
> >> This posting is provided "AS IS" with no warranties, and confers no
> >> rights.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.