Excel Application on server not working if admin user is logged out

2

I have a ASP.NET application which uses Microsoft intrope assemblies to read, write and modify excel files and it uses Excel 2013 on server machine. Application works fine if i am logged in to server machine as administrator but when i am logged out the application is unable to to initialize excel application. Here is the exception.

System.Runtime.InteropServices.COMException (0x8000401A)

Application is running on Windows Server 2008R2 with MS Excel 2013 32-bit I am not being able to figure out the reason of this behavior. Is this about COM objects security options or it has something to do with IIS permissions?

excel
iis-7
windows-server-2008-r2
excel-interop
asked on Stack Overflow May 7, 2015 by Addy • edited May 7, 2015 by Addy

2 Answers

5

The InteropServices class opens an (invisible) Excel instance to get its work done. Excel cannot run as a Windows service and needs to be instanciated by a logged on user.

"Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment." See this page for more information: Office support: Considerations for server-side Automation of Office

If you still want to keep the interop service, try change it to run as an interactive user:

  • Open Component Services (Start -> Run -> MMC comexp.msc /32)
  • Find Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application
  • Right click, choose properties
  • Go to the Identity tab and choose Interactive user
  • If this is not working, you can try to manually enter the user credentials

Of course, you could also switch to another framework to read the file. SO: How to read an excel file in C# without using Microsoft.Office.Interop.Excel libraries

answered on Stack Overflow May 7, 2015 by Physikbuddha • edited May 23, 2017 by Community
0

I had the same problem after migrating from 2008r2 to 2012. My solution:

  • Find Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application
  • Right click, choose properties
  • Go to the Identity tab and choose This user (input user & password)
answered on Stack Overflow Sep 1, 2017 by Jorge Mieses • edited Sep 1, 2017 by vich

User contributions licensed under CC BY-SA 3.0