excel interops OK with Excel 2003 with 'Office 2007 Compatability Pack'?

0

I'm maintaining a web-app which currently references Interop.Excel.dll (v 1.5.0.0).

The Interop.Excel.dll been used to access .xls files under Excel 2003 and then, subsequently, .xlsx/m files under Excel 2010. All worked fine.

The web-app got moved onto another machine (which has Excel 2003 with 'Office 2007 Compatability Pack' installed) and is now unable to open .xlsx/m files (stacktrace of error the occurs shown below).

There's no problem about a human opening .xlsx/m files on that machine other than you see the little Compatability Pack 'converting' dialog for a moment as the file is opened.

Is there some known limitation of combining : Excel 2003; 'Office 2007 Comp Pack'; and .xlsx/m files ?

STACKTRACE

2013-04-23 16:03:00.7192|Error|An error occurred in OpenCloseManager. Details Follow: 
Exception Type ---
System.Runtime.InteropServices.COMException
Message ---
The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
HelpLink ---

Source ---
Interop.Excel
StackTrace ---
   at Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
   at TCG.CRRExDBInterface.BO.SpreadSheetHelper.manageExcelOpen(Boolean blnUpdateLinks) in D:\foo\ExcelDBInterface-4.7.1.0\ExcelDBInterface-4.7.1.0\ExcelDBInterface\CRRExDBInterface\App_Code\BusinessObject\SpreadSheetHelper.cs:line 1920
TargetSite ---
Excel.Workbook Open(System.String, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object, System.Object)|MasterSubPage.parseSecurityInfoFromSpreadsheetAndSave => SpreadSheetHelper..ctor => SpreadSheetHelper.manageExcelOpen
c#
asp.net
excel
office-interop
asked on Stack Overflow Apr 23, 2013 by shearichard

2 Answers

0

Brave soul was the one to put office interop in a web app. If you check the documentation using the COM API is not recommended on a server for a two main reasons:

  • it's designed to work in a single threaded apartment ([STAThread] on your Main()) and multithreading is definitely not supported. Put some logging around the API call that fails and output the thread name and appdomain name - these will vary by web call and if you instantiate an Excel object on one thread and use it on another it's not going to work.
  • it relies on UI structures, even when the app is not visible - for example if you cause Word (I suspect Excel as well) to show a popup while the app is hidden the result will be as if the office API call is hanging. Check your server's accounts and make sure your web app is using an account that doesn't restrict that.

In either case I doubt the version of Excel is where your problem is.

If I were you I'd recommend to "management" to upgrade the app with OpenXmlSDK. It's not an easy switch but depending on your circumstances it can be worth its while - you can multithread, no hanging hidden instances etc, it's much faster, you have good control over what's happening. The drawbacks are a steep learning curve, lack of copy/paste type of functionality - one has to work around

answered on Stack Overflow Apr 23, 2013 by Sten Petrov
0

Well for it's worth (and to give this question some resolution) I gave up trying to use the old machine and moved to the machine with Excel 2010 installed. Not really an answer at all but, I hope, some indication to others that it wasn't solvable with the resources I had to hand.

answered on Stack Overflow May 2, 2013 by shearichard

User contributions licensed under CC BY-SA 3.0