Error:System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM cl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Parvati
    New Member
    • Feb 2013
    • 14

    Error:System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM cl

    Hi all,

    I am migrating an hosted application to another Server,hosting is done while generating MS documents and downloading buttons are clicked then getting error like Error:System.Ru ntime.InteropSe rvices.COMExcep tion (0x80080005): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80080005.

    Please help me out..... :(

    Thanks

    Parvati
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It's hard to say without seeing the code that causes the error. But the most likely cause is that Microsoft Office is not installed on the server.

    Comment

    • Parvati
      New Member
      • Feb 2013
      • 14

      #3
      Thanks Rabbit for reply,
      Error::System.R untime.InteropS ervices.COMExce ption (0x80080005): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80080005. at APP1.App2.Meeti ngDocuments.Mai lMerge(String sFileName, String sLoadFile, String sTempFileName, String sHeaderNames, ArrayList ArrData, Int32 randomNum)




      MeetingDocument s is aspx page,
      code:

      Code:
      public void MailMerge(string sFileName, string sLoadFile, string sTempFileName, string sHeaderNames, ArrayList ArrData, int randomNum)
              {
                  /*************************************/
                  Microsoft.Office.Interop.Word.Application wrdApp = null;
                  Microsoft.Office.Interop.Word._Document wrdDoc = null;
                  Microsoft.Office.Interop.Word.Selection wrdSelection = null;
                  Object oMissing = System.Reflection.Missing.Value;
                  object oTrue = true;
                  object oFalse = false;
                  Object miss = Type.Missing; 
                  try
                  {
      
                      //=========== Deleting the documents in the folder ======================
      
                      string Folder = Server.MapPath("TempDoc");
      
                      string[] FileList = Directory.GetFiles(Folder, "*.doc");
      
      
                      foreach (string img in FileList)
                      {
                          FileInfo Info = new FileInfo(img);
                          if (Info.Name.Contains(Session["SessUser"].ToString().Trim()))
                          {
                              try
                              {
                                  System.IO.File.Delete(Server.MapPath("TempDoc\\") + Info.Name);
                              }
                              catch (Exception ex)
                              {
                                  // Ignore
                              }
                          }
                      }
      
      
      
      
      
      
      
      
                      //Microsoft.Office.Interop.Word.Selection wrdSelection;
                      Microsoft.Office.Interop.Word.MailMerge wrdMailMerge;
                      Microsoft.Office.Interop.Word.MailMergeFields wrdMergeFields;
      
      
                      object fileName = Server.MapPath(sFileName);
      
      
      
      
      
            
      
                      Random rndm = new Random();
      
                      documentNumber = rndm.Next();
      
                      string sFileTemp = Server.MapPath("TempDoc\\" + Session["SessUser"].ToString() + randomNum + ".doc");
      
                      
      
      
                      if (System.IO.File.Exists(sFileTemp)) System.IO.File.Delete(sFileTemp);
      
                      wrdApp = new Microsoft.Office.Interop.Word.Application();
                      wrdDoc = wrdApp.Documents.Add(ref fileName, ref miss, ref miss, ref miss);
                      wrdDoc.Select();
                      wrdSelection = wrdApp.Selection;
                      wrdMailMerge = wrdDoc.MailMerge;
      
                      if (sFileName == "MasterContracts/Speakers_Letter.doc")
                      {
                          FormatSpeakerLetter(wrdDoc, ArrData);
                      }
      
                      //Calling Destination File
                      DestinationDoc(sTempFileName, sHeaderNames, ArrData, ref wrdDoc, ref wrdApp);// change for test
      
                      wrdMergeFields = wrdMailMerge.Fields;
      
                      wrdMailMerge.Destination = Microsoft.Office.Interop.Word.WdMailMergeDestination.wdSendToNewDocument;
                      wrdMailMerge.Execute(ref oFalse);
      
                      object fileName1 = Server.MapPath(sTempFileName);
      
                      fileName1 = Server.MapPath("TempDoc\\" + sLoadFile);
      
                      wrdApp.ActiveDocument.SaveAs(ref fileName1, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss,
                          ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
                      //wrdApp.ActiveDocument.Save();
                      wrdApp.Visible = false;
      
                      //wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);   // Commented for Test             
                      //wrdApp.ActiveDocument.Close(ref oTrue, ref miss, ref miss);// Commented for Test
      
                      string sFile = Server.MapPath("TempDoc\\" + Session["SessUser"].ToString() + randomNum + ".doc");
                      //if (System.IO.File.Exists(sFile)) System.IO.File.Delete(sFile);
                      //wrdApp.ShowMe();
      
                      //Response.ContentType = "application/ms-word";
                      //Response.AddHeader("Content-Disposition", "inline;filename=new.doc");
                      //Response.WriteFile("MasterContracts\\" + Session["SessUser"].ToString() + "1.doc");
                      //wrdApp.ActiveDocument.Close(ref oTrue, ref miss, ref miss);
                      //wrdApp.Quit(ref oMissing, ref oMissing, ref oMissing);// Commented for Test
                      //this.RegisterClientScriptBlock("Script1", "<script language='JavaScript'> RequestInfo('" + Session["SessFileName"].ToString() + "'); </script>");
                      //Response.Write("<script type='text/javascript'>detailedresults=window.open('WordOpen.aspx');</script>");
                  }
                  catch (Exception ex)
                  {
                      //wrdApp.Quit(ref oMissing,ref oMissing,ref oMissing);
                      Response.Write("Error:" + ex);
                      BE.DAL.Error.WriteErrorLog(ex);
                  }
                  finally
                  {
                      if (wrdDoc != null)
                      {
                          wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
                          wrdApp.ActiveDocument.Close(ref oTrue, ref miss, ref miss);
                      }
      
                      if (wrdApp != null)
                      {
                          wrdApp.Quit(ref oMissing, ref oMissing, ref oMissing);
                      }
                  }
              }

      here i have Button called Generate on aspx,when i click that button getting this error,
      Last edited by Rabbit; Feb 7 '13, 06:26 AM. Reason: Please use code tags when posting code.

      Comment

      • Parvati
        New Member
        • Feb 2013
        • 14

        #4
        actually onclicking that Generate Button word doc will create in folder called TempDoc

        Thanks
        Parvati

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          And which line generates the error?

          Comment

          • Parvati
            New Member
            • Feb 2013
            • 14

            #6
            Hi Rabbit,
            i think from this I m getting Error void MailMerge(strin g sFileName, string sLoadFile, string sTempFileName, string sHeaderNames, ArrayList ArrData, int randomNum),actu ally I got this Application to migrate from one server to another ,before that i m doing it on my local system.

            Is this Issue from Microsoft.Offic e.Word dll ??

            Comment

            • Parvati
              New Member
              • Feb 2013
              • 14

              #7
              Hi Rabbit,
              Before i was getting error like this,
              Error :System.Unautho rizedAccessExce ption;Retriving the COM class factory for component with CLSID {000209FF-0000-0000-C000-00000000046}fai led due to the following error:8007005 at MailMerge(strin g sFileName, string sLoadFile, string sTempFileName, string sHeaderNames, ArrayList ArrData, int randomNum)

              then i did changes in security,Compon et Service,Registr y then error changes to above one what i have mentioned ,in earlier post


              Thanks
              Parvati

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                No, your new error is a security error, you messed up the security when you were making changes.

                Your old error, I still need information. You never answered my question about which line caused the error. All you told me was the function that caused it. I need to know which line in that function caused it.

                Comment

                • Parvati
                  New Member
                  • Feb 2013
                  • 14

                  #9
                  Hi Rabbit,

                  Whenever I try to debug the code,getting error like

                  Warning 1 C:\Users\Parvat i\Desktop\Migra tionAspx\Migrat ionAspx\SNW\Sou rce\SpeakerAdmi n\MeetingDocume nts.aspx: ASP.NET runtime error: Could not load file or assembly 'Microsoft.Web. Extensions, Version=1.0.610 25.0, Culture=neutral , PublicKeyToken= 31bf3856ad364e3 5' or one of its dependencies. The system cannot find the file specified. (C:\Users\Parva ti\Desktop\Migr ationAspx\Migra tionAspx\SNW\So urce\SpeakerAdm in\web.config line 82) C:\Users\Parvat i\Desktop\Migra tionAspx\Migrat ionAspx\SNW\Sou rce\SpeakerAdmi n\MeetingDocume nts.aspx 1 1 C:\...\Source\

                  and

                  Error 102 Could not load file or assembly 'Microsoft.Web. Extensions, Version=1.0.610 25.0, Culture=neutral , PublicKeyToken= 31bf3856ad364e3 5' or one of its dependencies. The system cannot find the file specified.

                  I think this is because of Ajax Controls they have used in application and there are dlls like
                  1)Microsoft.Off ice.Interop.Wor d.dll
                  Microsoft.Offic e.Interop.Word. xml
                  2)Microsoft.Web .Extension.Desi gn.dll
                  3)Microsoft.Web .Extension.dll


                  When i click on that warning then cursor goes to aspx page Source there they have used
                  Code:
                  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MeetingDocuments.aspx.cs" Inherits="SpeakerNetwork.Allthebestspeakers.MeetingDocuments" %>
                  
                  <%@ Register Src="UserControls/TopUserControl.ascx" TagName="TopUserControl" TagPrefix="uc3" %>
                  
                  <%@ Register Src="UserControls/BottomUserControl.ascx" TagName="BottomUserControl"
                      TagPrefix="uc2" %>
                  
                  <%@ Register Src="UserControls/LeftMenu.ascx" TagName="LeftMenu" TagPrefix="uc1" %>
                  
                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  
                  <html xmlns="http://www.w3.org/1999/xhtml" >
                  <head runat="server">
                      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                      <title><%=CommonUI.GetSiteName() %></title>
                      <link href="css/style.css" rel="stylesheet" type="text/css" />
                      <style>
                          body
                          {
                              background-image:url(images/background.jpg);
                          }
                      </style>
                      
                      <script language="javascript" type="text/javascript" id="Script1">
                          function WordOpen() {
                              window.open("WordOpen.aspx");
                          }        
                  	
                          function RequestInfo(sFileName) {
                            var r=confirm("Do you want to download the " + sFileName + " ?");
                            
                            if (r==true)    
                              WordOpen();    
                            else    
                              return false;    
                          }
                          
                          function EmailWindowOpen() {
                              window.open("SendDocMail.aspx","Sample","toolbar=no,width=700,height=500,left=200,top=150,status=no,scrollbars=yes,resize=no");
                              
                          }

                  Comment

                  • Parvati
                    New Member
                    • Feb 2013
                    • 14

                    #10
                    Actually They have used Framework 2.0 and i m trying to executing it on Framework 4.0

                    Comment

                    • Parvati
                      New Member
                      • Feb 2013
                      • 14

                      #11
                      Hi all ,

                      Finally I got solution,we have to installed .NET Component called “.NET Programmability ” in the office installation. Once its installed successfully go to “Component Services” in the Control Panel then Component Services  DCOM Config  MS Word Document. In the properties you have to give permission to launch word document via programmaticall y (assign Network, NetworkServices and Root/Admin users).

                      Comment

                      Working...