473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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

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

10 18494
Rabbit
12,516 Expert Mod 8TB
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
Parvati
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
Parvati
14
actually onclicking that Generate Button word doc will create in folder called TempDoc

Thanks
Parvati
Feb 7 '13 #4
Rabbit
12,516 Expert Mod 8TB
And which line generates the error?
Feb 7 '13 #5
Parvati
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
Parvati
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
12,516 Expert Mod 8TB
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
Parvati
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
Parvati
14
Actually They have used Framework 2.0 and i m trying to executing it on Framework 4.0
Feb 8 '13 #10
Parvati
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

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

Similar topics

0
by: Logan McKinley | last post by:
I need to access a function from a dll but am having problems with the conversion. the def from the documentation is: extern "C" __stdcall int tira_get_captured_data_vb ( unsigned char data,...
0
by: Dennis | last post by:
Greetings, I am having a wierd problem with .net accessing the clipboard on certain machines. The code copies the RTF formatted data from the clipboard. I first try and retrieve the clipboard...
0
by: MickeBoy | last post by:
Hi all! I have a problem and I don't know what to do. I have written an web application in asp.net using C# as language. The application calls an external dll written in VS.NET C++. On my...
2
by: Abc | last post by:
System.Runtime.InteropServices.MarshalDirectiveException This is the exception which i am getting while running a code . Can any one help me out to resolve it? Thanks.
1
by: umeshatpromact | last post by:
Hello!, I got following exception when using COM component for EXCEL object in ASP .Net. I have added reference of "Microsoft.Office.Interop.Excel.dll" I deployed an application on local...
1
by: sasikumarks | last post by:
Hi, Im using the following code to retrieve the user details from the AD server. But when i execute the code,it throws me the error. Please help me in this...
1
by: johnxhc | last post by:
I have the big application, it has C#, VB.NET, VB6 & VC++ components, those components calling each other, passing the objects between the managed & unmanaged layer. The application crashes in...
1
by: wagugwe | last post by:
Dear all, Am faced with the above problem. I am designing an application in VB.Net 2003 and using Ms Access 2000 as the database. I have the following code: Private Sub cmdSave_Click(ByVal...
0
by: ellen2008 | last post by:
Hi! I am trying to run another person's code on my pc. The code compiles fine. But when running, it gave the following message: Error Message: System.Runtime.InteropServices.COMExceptiion...
2
by: sriregu | last post by:
Hi, i am trying the exe file in .net environment and am getting the following error.Any idea how i can resolve it? System.Runtime.InteropServices.COMException (0x80040154): Class not registered ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.