Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154
November 3, 2009 by Nauman · 14 Comments
Sometimes when working with office Interop assemblies the above mentioned error occurs. I had also got the same when using Microsoft Excel interop assembly and adding its reference in my ASP.NET application.
The problem is that by default when Microsoft Excel is used as a COM object then it can only be activated by the following accounts:
- Administrator
- System
- Interactive
And when you are running your web application on windows server 2003, it is running under ASPNET account.
The way to resolve this issue is to edit the DCOM configuration settings for Microsoft Excel Application object.
Configure DCOM
- Go to Start -> Run.
- Type DCOMCNFG. (This will load the "Component Services")
- Go to Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application.
- Right click and select Properties.
- Select the Security tab.
Press Add button to select the "Network Service" account.
Click the OK button, and then test your application, it should work fine now.
hmm, now i got it…. thanks for sharing.
if microsoft office is not there in my system..then what to do.can you help me?
some guys said to use 32 bit OS, im using . And im not using this excel object. im using vendors dll meant for vb.net wch I converted using tlbimp to be used in my c# code and now getting the error com class factory ….. any idea to workaround??
hi i done all those things which mentioned above but i cant find solution. still i am getting this error.
My doubt is whether there’s relation between administrator Login or Ordinary user Login
you have to use Admin Login for changing Excel properties.
i am not getting the “Microsoft Excel Application” in the list of Components under the hierarchy….what could be the issue?
Please help me out….
Is Microsoft Office fully installed on your system?
private void button1_Click(object sender, EventArgs e)
{
// creating Excel Application
Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
// creating new WorkBook within Excel application
Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
// creating new Excelsheet in workbook
Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
// see the excel sheet behind the program
app.Visible = true;
// get the reference of first sheet. By default its name is Sheet1.
// store its reference to worksheet
worksheet =(_Worksheet) workbook.Sheets["Sheet1"];
worksheet = (_Worksheet)workbook.ActiveSheet;
// changing the name of active sheet
worksheet.Name = “Exported from gridview”;
// storing header part in Excel
for (int i = 1; i < dataGridView1.Columns.Count + 1; i++)
{
worksheet.Cells[1, i] = dataGridView1.Columns[i - 1].HeaderText;
}
// storing Each row and column value to excel sheet
for (int i = 0; i < dataGridView1.Rows.Count – 1; i++)
{
for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
worksheet.Cells[i + 2, j + 1] = dataGridView1.Rows[i].Cells[j].Value.ToString();
}
}
// storing Each row and column value to excel sheet
for (int i = 0; i < dataGridView1.Rows.Count – 1; i++)
{
for (int j = 0; j Microsoft.Office.Interop.Excel._Application app = new
Microsoft.Office.Interop.Excel.Application(); it show error
can any help to get data in gridview and then it posted in excel sheet using windows application and c#.net.
Hello how are you, I did the process to run application on the server, but the truth does not work for me now I is generating another error when trying to open the file, the error is as follows “Error in remote procedure call. (Exception from HRESULT: 0x800706BE) “could help me I would appreciate
Thanks !!!!
Thks for ur help.. its working fine for me
Do we need to have excel already installed on the Windows Server 2003 machine.
-Rajeev
http://magazineforipad.com
I had the same problem running C# code with reference to a COM dll.
Changing platform from AnyCPU to x86 didn’t help.
Changing the reference property “Isolated” to True inside the C# project, solved the problem.
Also, all the files created by compilation should be copied together with exe:
*.exe.manifest
*.pdb
*.vshost.exe
Interop.*.dll
Was getting this error for a long time, resolved now
Thank you for clear instructions!
Also though you have tried to explain why this alert was occuring, however I still haven’t got it… my head needs more explanation