I am using a Windows based application which uses COM Interop Excel in which the excel exports fails. This works in the development environment. But it fails when promoted to other environment.
Also the problem is it is not reproducible in local environment.
We are using Microsoft.Interop.Excel for opening the excel and updating the data.
While trying to add the workbook using Workbooks.Add method we are getting the following
error :
System.Runtime.InteropServices.COMException.Exception from HRESULT:0X800A03EC
at Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template)
Code :
thisWorkbook = OpenTemplate(new System.IO.FileInfo("XLSTemplate\\Test.xlsx"));
public Workbook OpenTemplate(FileInfo xlsFile)
{
Workbook wb = null;
try
{
wb = Workbooks.Add(xlsFile.FullName);
template = xlsFile;
if (wb != null)
{
if (!DebugOut.IsDebug & wb.Worksheets.Count > 0)
((_Worksheet)wb.Worksheets[1]).Activate();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
throw new Exception("Error in OpenTemplate",ex);
}
return wb;
}
Any help and solution would be much appreaciated.
Are the OS different in both environment? Is it Window 2008 Server? If so try creating Desktop folder as below if not present already in the environment where this is failing.
Windows 2008 Server (64 Bit): C:\Windows\SysWOW64\config\systemprofile\Desktop
Windows 2008 Server (32 Bit): C:\Windows\System32\config\systemprofile\Desktop
Solution 2:
Vào IIS chọn Application Pools --> Click phải vào website --> Advanced Settings --> như hình (lưu ý: phải chọn Identity sang LocalSystem)
Nguồn: https://www.codeproject.com/Questions/574791/COMplusExceptionplushresultplus0x800a03ecplusatplu