I have a C# .net web app. I want a user to click a button on a webpage, the server to open an excel spreadsheet and write data to it, and the user to save the document. This works locally using Visual Studio 2010 and Office 2010. On my server, however, I get this error:
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
I have researched and found a ton of answers stating to open dcomconfig and add the user with permissions to Microsoft Excel Application. My site is set to passthrough security so I added myself; I am an admin on the server, so I ensured Admins had access; I also added the App Pool default of Network Service; also ASP.NET Machine Account; and, just in case, added the account the app uses when connecting to the database. I still get the exact same error.
My server is 64 bit, Office 2007, IIS 7.
My code is:
{
try
{
Excel.Application xXL = null;
Excel.Workbook xWB = null;
Excel.Worksheet xSheet = null;
xXL = new Excel.Application();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…