Monday, February 6, 2012

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 · 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.

CreatingApplication

 

 

 

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:

  1. Administrator
  2. System
  3. 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

  1. Go to Start -> Run.
  2. Type DCOMCNFG. (This will load the "Component Services")
  3. Go to Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application.
  4. Right click and select Properties.
  5. Select the Security tab.

ExcelProperties

 

 

 

 

 

 

 

 

 

 

 

  • In "Launch and Activate Permissions" select Customize and press the Edit button.
  • LaunchPermission

     

     

     

     

     

     

     

     

     

     

    Press Add button to select the "Network Service" account.

    SelectUser

     

     

     

     

     

    ShowPermissions

     

     

     

     

     

     

     

     

     

     

    Click the OK button, and then test your application, it should work fine now.

    Top Blogs

    Comments

    14 Responses to “Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154”
    1. Oes Tsetnoc Punk Poser says:

      hmm, now i got it…. thanks for sharing.

    2. Suneetha says:

      if microsoft office is not there in my system..then what to do.can you help me?

    3. abid says:

      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??

    4. muthuraj.net@gmail.com says:

      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

    5. Nauman says:

      you have to use Admin Login for changing Excel properties.

    6. ravi lele says:

      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….

      :(

    7. Nauman says:

      Is Microsoft Office fully installed on your system?

    8. navaz says:

      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.

    9. 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 !!!!

    10. Guna says:

      Thks for ur help.. its working fine for me

    11. Rajeev says:

      Do we need to have excel already installed on the Windows Server 2003 machine.

      -Rajeev

      http://magazineforipad.com

    12. Irina says:

      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

    13. Niki says:

      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 :-)

    Trackbacks

    Check out what others are saying about this post...


    Speak Your Mind

    Tell us what you're thinking...
    and oh, if you want a pic to show with your comment, go get a gravatar!

    *