MS, seriously!!! SSIS and System.Runtime.InteropServices.COMException (0x800A03EC)

Let me describe my problem. Maybe you have the same, if you have googled for the error code, and found this page.

So, I’m downloading an old Excel file from a German webpage. The Excel file is in a spreadsheetML format, which is impossible to read from SSIS.

No worries, I can easily with a script task, convert the file to CSV, using C# and the Excel API. Like so

….
using MS.Internal.Xml;
using Microsoft.Office.Interop.Excel;
…….

Microsoft.Office.Interop.Excel.Workbook wb1 ;
Microsoft.Office.Interop.Excel.Application wb2 =
new Microsoft.Office.Interop.Excel.Application();
wb2.DisplayAlerts = false;
wb1 = (Microsoft.Office.Interop.Excel.Workbook)wb2.Workbooks._Open(filename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

if (wb1.FileFormat == Microsoft.Office.Interop.Excel.XlFileFormat.xlXMLSpreadsheet)
{
wb1.SaveAs(filename.Replace(“.xls”,”.csv”) , Microsoft.Office.Interop.Excel.XlFileFormat.xlCSVMSDOS , Type.Missing, Type.Missing, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,false,false,false,false,false);
}
else
{
wb2.Workbooks.Close();
}
wb2.Workbooks.Close();

Now I can read the data with a SSIS CSV data source. This Works fine, when I run my SSIS package from BIDS. When I put it in to production, and run the package with the SQL server agent, I get the following error:

Service cannot be started. System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file ‘c:\XXXX’. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.

None of the above is my problem. I think I tried everything to find a solution to the problem. It turns out, that it is a bug in windows server 2008. There are some different solutions on the web, which include changing the registry values on the server.

Since I’m a consultant, and hence an expensive resource, I would like not to fuck anything up, playing around with registry values.

I found an easier fix however. Apparently, the folder C:\Windows\SysWOW64\config\systemprofile\Desktop has been removed from Windows server 2008. It was present in windows server 2003.

When I created the folder, everything worked fine. Apparently the desktop folder is necessary, if you want to manipulate Excel files with code from the SQL server agent. Scary.

So, the answer: if you have problems manipulating office files from code executed from the SQL server agent on windows server 2008 create the folder C:\Windows\SysWOW64\config\systemprofile\Desktop (C:\Windows\System32\config\systemprofile\Desktop if it is 32bit)

That was it for now. Bye bye:-)

20 thoughts on “MS, seriously!!! SSIS and System.Runtime.InteropServices.COMException (0x800A03EC)

  1. Nithesh Erakkara

    Hi Claus,

    I’m trying to read excel file from SharePoint 2010. I was also facing the problem mentioned above. I have created the folder and gave full control rights to IIS AppPool\DefaultAppPool on the folder. Still I’m getting COM Exception.

    Can you guide me what more I can do?

  2. Claus Post author

    Hi Nithesh,

    No, sorry, it is to long ago 🙁 If the above don’t work, then I don’t know how to fix it 🙁

  3. Falak Shah

    Thanks man your solution worked absolutely fine.

    I am not sure why Excel object need “Desktop” folder over there.

    How could we manage to create on User’s machines. ?

  4. Christopher Haws

    You rule. I have been trying to figure this out for the last 12 hours and came across your blog post. Worked like a charm!!

  5. Andres Botero

    Seriously, if I could kiss you, I would. Thank you so much! I had tried everything 🙂

  6. JC

    Unbelievable! Just when you think you have seen everything… I think someone should write a book on work arounds and fixes for this stuff

    Thank You!

  7. Felix

    Thank you very much! You saved my day!
    I was facing this problems since a few weeks and couldn’t find a solution so far, your’s helped!

  8. Robert Simpson

    Wow. Been working on this issue off and on for a number of days, and now that I finally got it to spit out an HRESULT, your post is the solution. Thanks much!

  9. Thuan Tran

    Awesome .. I was pulling my hair out on this too .. I test my code via win32 app and it works there. But it failed when I build my window service. Creating the Desktop folder save the day. Thanks much

  10. David

    I’ve been debugging what I thought were permission issues related to our service account the entire day with no success. Finally stumbled upon your post. Your solution worked. I can’t believe it worked, but it did!! Thank you! Are you kidding me MSFT?!

  11. DW

    I have no luck, The desktop folder has created both the server where i run the package, and the machine where i stored the excel file. any other posiblity solutions?

  12. DW

    Finally i get this work if DESKTOP folder did not help,

    Start
    Run
    mmc -32
    File
    Add Remove Snap-in
    Component Services
    Add
    OK
    Console Root
    Component Services
    Computers
    My Computer
    DCOM Config
    Microsoft Excel Application -> Right click -> Properties
    On Security tab, give full permissions to the domain user and NT SERVICE\SQLSERVERAGENT on: a. Launch and Active Permissions b. Access Permissions c. Configuration Permissions
    On Identiy tab -> change to Interactive User

    from this post:https://stackoverflow.com/questions/35642527/unhandled-exception-system-runtime-interopservices-comexception-0x800a03ec

    Cheers!!

Leave a Reply

Your email address will not be published. Required fields are marked *