By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

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

P: 14
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.Runtime.InteropServices.COMException (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
Feb 6 '13 #1

✓ answered by Parvati

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 programmatically (assign Network, NetworkServices and Root/Admin users).

Share this Question
Share on Google+
10 Replies


Rabbit
Expert Mod 10K+
P: 12,347
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.
Feb 6 '13 #2

P: 14
Thanks Rabbit for reply,
Error::System.Runtime.InteropServices.COMException (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.MeetingDocuments.MailMerge(String sFileName, String sLoadFile, String sTempFileName, String sHeaderNames, ArrayList ArrData, Int32 randomNum)




MeetingDocuments is aspx page,
code:

Expand|Select|Wrap|Line Numbers
  1. public void MailMerge(string sFileName, string sLoadFile, string sTempFileName, string sHeaderNames, ArrayList ArrData, int randomNum)
  2.         {
  3.             /*************************************/
  4.             Microsoft.Office.Interop.Word.Application wrdApp = null;
  5.             Microsoft.Office.Interop.Word._Document wrdDoc = null;
  6.             Microsoft.Office.Interop.Word.Selection wrdSelection = null;
  7.             Object oMissing = System.Reflection.Missing.Value;
  8.             object oTrue = true;
  9.             object oFalse = false;
  10.             Object miss = Type.Missing; 
  11.             try
  12.             {
  13.  
  14.                 //=========== Deleting the documents in the folder ======================
  15.  
  16.                 string Folder = Server.MapPath("TempDoc");
  17.  
  18.                 string[] FileList = Directory.GetFiles(Folder, "*.doc");
  19.  
  20.  
  21.                 foreach (string img in FileList)
  22.                 {
  23.                     FileInfo Info = new FileInfo(img);
  24.                     if (Info.Name.Contains(Session["SessUser"].ToString().Trim()))
  25.                     {
  26.                         try
  27.                         {
  28.                             System.IO.File.Delete(Server.MapPath("TempDoc\\") + Info.Name);
  29.                         }
  30.                         catch (Exception ex)
  31.                         {
  32.                             // Ignore
  33.                         }
  34.                     }
  35.                 }
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.                 //Microsoft.Office.Interop.Word.Selection wrdSelection;
  45.                 Microsoft.Office.Interop.Word.MailMerge wrdMailMerge;
  46.                 Microsoft.Office.Interop.Word.MailMergeFields wrdMergeFields;
  47.  
  48.  
  49.                 object fileName = Server.MapPath(sFileName);
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.                 Random rndm = new Random();
  58.  
  59.                 documentNumber = rndm.Next();
  60.  
  61.                 string sFileTemp = Server.MapPath("TempDoc\\" + Session["SessUser"].ToString() + randomNum + ".doc");
  62.  
  63.  
  64.  
  65.  
  66.                 if (System.IO.File.Exists(sFileTemp)) System.IO.File.Delete(sFileTemp);
  67.  
  68.                 wrdApp = new Microsoft.Office.Interop.Word.Application();
  69.                 wrdDoc = wrdApp.Documents.Add(ref fileName, ref miss, ref miss, ref miss);
  70.                 wrdDoc.Select();
  71.                 wrdSelection = wrdApp.Selection;
  72.                 wrdMailMerge = wrdDoc.MailMerge;
  73.  
  74.                 if (sFileName == "MasterContracts/Speakers_Letter.doc")
  75.                 {
  76.                     FormatSpeakerLetter(wrdDoc, ArrData);
  77.                 }
  78.  
  79.                 //Calling Destination File
  80.                 DestinationDoc(sTempFileName, sHeaderNames, ArrData, ref wrdDoc, ref wrdApp);// change for test
  81.  
  82.                 wrdMergeFields = wrdMailMerge.Fields;
  83.  
  84.                 wrdMailMerge.Destination = Microsoft.Office.Interop.Word.WdMailMergeDestination.wdSendToNewDocument;
  85.                 wrdMailMerge.Execute(ref oFalse);
  86.  
  87.                 object fileName1 = Server.MapPath(sTempFileName);
  88.  
  89.                 fileName1 = Server.MapPath("TempDoc\\" + sLoadFile);
  90.  
  91.                 wrdApp.ActiveDocument.SaveAs(ref fileName1, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss,
  92.                     ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
  93.                 //wrdApp.ActiveDocument.Save();
  94.                 wrdApp.Visible = false;
  95.  
  96.                 //wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);   // Commented for Test             
  97.                 //wrdApp.ActiveDocument.Close(ref oTrue, ref miss, ref miss);// Commented for Test
  98.  
  99.                 string sFile = Server.MapPath("TempDoc\\" + Session["SessUser"].ToString() + randomNum + ".doc");
  100.                 //if (System.IO.File.Exists(sFile)) System.IO.File.Delete(sFile);
  101.                 //wrdApp.ShowMe();
  102.  
  103.                 //Response.ContentType = "application/ms-word";
  104.                 //Response.AddHeader("Content-Disposition", "inline;filename=new.doc");
  105.                 //Response.WriteFile("MasterContracts\\" + Session["SessUser"].ToString() + "1.doc");
  106.                 //wrdApp.ActiveDocument.Close(ref oTrue, ref miss, ref miss);
  107.                 //wrdApp.Quit(ref oMissing, ref oMissing, ref oMissing);// Commented for Test
  108.                 //this.RegisterClientScriptBlock("Script1", "<script language='JavaScript'> RequestInfo('" + Session["SessFileName"].ToString() + "'); </script>");
  109.                 //Response.Write("<script type='text/javascript'>detailedresults=window.open('WordOpen.aspx');</script>");
  110.             }
  111.             catch (Exception ex)
  112.             {
  113.                 //wrdApp.Quit(ref oMissing,ref oMissing,ref oMissing);
  114.                 Response.Write("Error:" + ex);
  115.                 BE.DAL.Error.WriteErrorLog(ex);
  116.             }
  117.             finally
  118.             {
  119.                 if (wrdDoc != null)
  120.                 {
  121.                     wrdDoc.Close(ref oFalse, ref oMissing, ref oMissing);
  122.                     wrdApp.ActiveDocument.Close(ref oTrue, ref miss, ref miss);
  123.                 }
  124.  
  125.                 if (wrdApp != null)
  126.                 {
  127.                     wrdApp.Quit(ref oMissing, ref oMissing, ref oMissing);
  128.                 }
  129.             }
  130.         }

here i have Button called Generate on aspx,when i click that button getting this error,
Feb 7 '13 #3

P: 14
actually onclicking that Generate Button word doc will create in folder called TempDoc

Thanks
Parvati
Feb 7 '13 #4

Rabbit
Expert Mod 10K+
P: 12,347
And which line generates the error?
Feb 7 '13 #5

P: 14
Hi Rabbit,
i think from this I m getting Error void MailMerge(string sFileName, string sLoadFile, string sTempFileName, string sHeaderNames, ArrayList ArrData, int randomNum),actually 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.Office.Word dll ??
Feb 7 '13 #6

P: 14
Hi Rabbit,
Before i was getting error like this,
Error :System.UnauthorizedAccessException;Retriving the COM class factory for component with CLSID {000209FF-0000-0000-C000-00000000046}failed due to the following error:8007005 at MailMerge(string sFileName, string sLoadFile, string sTempFileName, string sHeaderNames, ArrayList ArrData, int randomNum)

then i did changes in security,Componet Service,Registry then error changes to above one what i have mentioned ,in earlier post


Thanks
Parvati
Feb 7 '13 #7

Rabbit
Expert Mod 10K+
P: 12,347
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.
Feb 7 '13 #8

P: 14
Hi Rabbit,

Whenever I try to debug the code,getting error like

Warning 1 C:\Users\Parvati\Desktop\MigrationAspx\MigrationAs px\SNW\Source\SpeakerAdmin\MeetingDocuments.aspx: ASP.NET runtime error: Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. (C:\Users\Parvati\Desktop\MigrationAspx\MigrationA spx\SNW\Source\SpeakerAdmin\web.config line 82) C:\Users\Parvati\Desktop\MigrationAspx\MigrationAs px\SNW\Source\SpeakerAdmin\MeetingDocuments.aspx 1 1 C:\...\Source\

and

Error 102 Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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.Office.Interop.Word.dll
Microsoft.Office.Interop.Word.xml
2)Microsoft.Web.Extension.Design.dll
3)Microsoft.Web.Extension.dll


When i click on that warning then cursor goes to aspx page Source there they have used
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MeetingDocuments.aspx.cs" Inherits="SpeakerNetwork.Allthebestspeakers.MeetingDocuments" %>
  2.  
  3. <%@ Register Src="UserControls/TopUserControl.ascx" TagName="TopUserControl" TagPrefix="uc3" %>
  4.  
  5. <%@ Register Src="UserControls/BottomUserControl.ascx" TagName="BottomUserControl"
  6.     TagPrefix="uc2" %>
  7.  
  8. <%@ Register Src="UserControls/LeftMenu.ascx" TagName="LeftMenu" TagPrefix="uc1" %>
  9.  
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11.  
  12. <html xmlns="http://www.w3.org/1999/xhtml" >
  13. <head runat="server">
  14.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  15.     <title><%=CommonUI.GetSiteName() %></title>
  16.     <link href="css/style.css" rel="stylesheet" type="text/css" />
  17.     <style>
  18.         body
  19.         {
  20.             background-image:url(images/background.jpg);
  21.         }
  22.     </style>
  23.  
  24.     <script language="javascript" type="text/javascript" id="Script1">
  25.         function WordOpen() {
  26.             window.open("WordOpen.aspx");
  27.         }        
  28.  
  29.         function RequestInfo(sFileName) {
  30.           var r=confirm("Do you want to download the " + sFileName + " ?");
  31.  
  32.           if (r==true)    
  33.             WordOpen();    
  34.           else    
  35.             return false;    
  36.         }
  37.  
  38.         function EmailWindowOpen() {
  39.             window.open("SendDocMail.aspx","Sample","toolbar=no,width=700,height=500,left=200,top=150,status=no,scrollbars=yes,resize=no");
  40.  
  41.         }
Feb 8 '13 #9

P: 14
Actually They have used Framework 2.0 and i m trying to executing it on Framework 4.0
Feb 8 '13 #10

P: 14
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 programmatically (assign Network, NetworkServices and Root/Admin users).
Feb 15 '13 #11

Post your reply

Sign in to post your reply or Sign up for a free account.