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?
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:
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
I had the same problem after migrating from 2008r2
to 2012
. My solution:
User contributions licensed under CC BY-SA 3.0