Solved

Issue with adding Excel COM reference in VS 2005 using Office 2003

Posted on 2011-02-16
6
285 Views
Last Modified: 2012-05-11
I have an application that was created using office 2003 and the Microsoft.Office.Interop.Excel.dll.  Everything has worked great for a year or so with the portion of the app that writes to Excel.  My pc was recently upgraded to Office 2010...so I had to remove the old and add the new references for Excel...again...no issues.  The problem was though, the app runs from Citrix, and since it has Office 2003, I needed to change them back...fine...no worries right?

Well, I made the changes on a pc with Office 2003, ran the app locally...everything worked.  Placed the app on the server and the Excel portion blows up.  It appears that when I added the Office 2K3 reference back in, it is now using Interop.Excel.dll...a different dll then what it was using before.

Now, I can just replace that other dll with the one it is currently using, but I want to know why it is using Interop.Excel.dll as opposed to Microsoft.Office.Interop.Excel.  I have tried this on a few pc's with Office 2K3 and I get the same result.
0
Comment
Question by:rgn2121
  • 3
  • 2
6 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 34906156
because you are targeting a different version, you have 2 options here:
-switch to late binding (do not add a reference and use GetObject to create your instance)
-use a 3rd party application like http://www.aspose.com/categories/.net-components/aspose.cells-for-.net/default.aspx
0
 
LVL 12

Author Comment

by:rgn2121
ID: 34906242
I am targeting Office 2003...only Office 2003.  The last time I add the reference it used Microsoft.Office.Interop.Excel.dll.  Now it uses Interop.Excel.dll...both for Office 2K3 (Office 11)
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 34906316
you are targeting Office 2003 but you have something different installed on your PC!
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 12

Author Comment

by:rgn2121
ID: 34906337
I have 2K3 on the PC's that I am developing on today...I have tried 2 office 2k3 pc's as stated above...
0
 
LVL 12

Accepted Solution

by:
Hairbrush earned 500 total points
ID: 34914669
Microsoft.Office.Interop.Excel.dll is a "Primary Interop Assembly" (PIA) which is the "official" interop assembly as distributed by Microsoft.  It is strongly named and installed in the GAC. The intention is that this assembly is used by all applications that need to call the Excel API.  (IF you have multiple versions of Office then you may have more than one Microsoft.Office.Interop.Excel.dll in your GAC as they will have different signatures - the version number will be different)

Your Interop.Excel.dll sounds like it has been generated by creating a reference directly to the Excel.exe COM object.  Microsoft recommends against referencing the Office applications in this way.  See the third article below.

Sounds like you do not have the Office 2003 PIAs on the server.  You can check by looking in the GAC.

http://msdn.microsoft.com/en-us/library/aax7sdch.aspx
http://msdn.microsoft.com/en-us/library/kh3965hw(VS.80).aspx
http://msdn.microsoft.com/en-us/library/dww0e04a(VS.80).aspx

Hope this helps.
0
 
LVL 12

Author Comment

by:rgn2121
ID: 34960317
Thanks Hairbrush...I was adding my references the way link 3 described, but it kept choosing the Interop.Excel.dll.  One pc had the Office 2003 PIA's installed the other did not.  I installed them on the pc that needed them and it selected the correct dll.  I found out that from another developer in my dept that he has to do this almost every time there is an office update...I just didn't know it since it had been so long since I have been in this application.

Thanks for the links...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now