We help IT Professionals succeed at work.

Exception from HRESULT: 0x800A03EC Interop Open Excel Workbook

WSIT
WSIT used Ask the Experts™
on
I have a c# prject which when running locally can happily open and save excel workbooks using automation.  When I put the project on a web server I get Exception from HRESULT: 0x800A03EC if I trry to open a workbook or save one.  I am able to obtain a list of the files in the folder in which the workbook is located.

Any help would be greatly appreciated.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC

Source Error:


Line 630:            Object objMissing = System.Reflection.Missing.Value;
Line 631:            object objFileFormat = (object)Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;
Line 632:            objBook = objBooks.Open(strFullPathToFile,
Line 633:                objMissing, //updatelinks
Line 634:                false, //readonly
 

Source File: c:\inetpub\wwwroot\WSWebServices\App_Code\Helpers.cs    Line: 632

Stack Trace:


[COMException (0x800a03ec): Exception from HRESULT: 0x800A03EC]
   Microsoft.Office.Interop.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) +0
   WSWebServices.App_Code.Helpers.GetExcelWorkSheet(String strFullPathToFile, Int32& intHwnd) in c:\inetpub\wwwroot\WSWebServices\App_Code\Helpers.cs:632
   ImportIdentityVerificationData.btnWorkWithFile_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WSWebServices\Surveys\ImportIdentityVerificationData.aspx.cs:219
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

 

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Commented:

Check out this link: It says this error can happen when regional settings in the server is different from the installed excel app...
=> http://www.made4dotnet.com/Default.aspx?tabid=141&aid=15

Solution it recommends is:

Save Current Culture of in 'initialCulture' variable
Set CurrentCulture to en-us

do all your excel interop code here...

Set Current culture back to initialCulture saved earlier
Top Expert 2010

Commented:

In addition to the culture issue, the cause for this COM error could be different things:

For the same error message:

This EE solution mentions to use System.Reflection.Missing.Value instead of passing null in open method - which you are already doing...(=> http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21267120.html)

This link mentions to use one Excel.Application, instead of creating Excel.Application for each workbook..check if you are doing this...(=> http://www.ureader.com/message/692318.aspx). Make sure you quit Excel.Application each time you are done with it.

But these above issues happen at very first time...in your case it works in local and not in server...so Current culture is more likely to be a cause than these...

Author

Commented:
I'm afraid this didn't solve the problem.  I can log on to the server locally and run function successfully on there.  It is only when I access the website from outside that I have the problem.  The site has many other pages which load successfully.  Is there an alternative to using Interop?
Top Expert 2010

Commented:
Some suggestions below:
It could be an issue with access permission to the excel file. Check the folder and the excel file have required permissions. What is the user account the wep app is running on...Try a debug line around the open excel code like:
Response.Write("Current User Name: " + User.Identity.Name);
Does this user have access to the excel file you are trying to open.
(=> http://www.bluevisionsoftware.com/WebSite/TipsAndTricksDetails.aspx?Name=AspNetAccount)

An alternative to using excel interop is to use ADO.NET with Microsoft.Jet.OLEDB driver. You can refer these links for more details:
=> http://www.davidhayden.com/blog/dave/archive/2006/05/26/2973.aspx)
=> http://support.microsoft.com/kb/316934

Commented:
I solved this problem myself by using ExcelLibrary which seems much less quirky than using Interop

Thanks anyway
WSIT - what Library?
I face the same problem.
Please help