Error: HttpException (0x80004005): 
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed 


Case: Automation of word document in ASP.Net works fine when in debug mode but when published, generates COM Class error.


1. in your web.config
<system.web>
...
 <identity impersonate="true" userName="allowedUserName.domain" password="thePassword"></identity>
</system.web>

2. in dcomcnfg
Component Service -> My computer -> DCOM Config


find MSWord Process, then set 
Security -> Launch And Activation Permissions, etc as "Customize".  Add user "allowedUserName.domain" with the following permissions: local launch = allow, local activation = allow









 
1. create a hyperlink in your web page
<asp:HyperLink ID="hyperLinkDownloadFile" runat="server">Download this file</asp:HyperLink>

2. in your code-behind
hyperLinkFileGen.Text = "click on this link to download the document";
hyperLinkFileGen.NavigateUrl = "downloadpage.aspx?file=yourDocument.ext";

3. create downloadpage.aspx
using System.IO;
  public partial class downloadpage: System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string filename = Request["file"].ToString();
            fileDownload(Server.MapPat(filename));
        }

        private void fileDownload(string filename)
        {
            System.IO.FileInfo theFile= new System.IO.FileInfo(fileName);
            if (file.Exists) {
                   Response.Clear();
                   Response.AddHeader("Content-Disposition", "attachment; filename=" + theFile.Name);
                   Response.AddHeader("Content-Length", theFile.Length.ToString());
                   Response.ContentType = "application/octet-stream";
                   Response.WriteFile(theFile.FullName);
                   Response.End();
            } else { Response.Write("This file does not exist."); }
       }
}



 
Ajax's update panel provides an easy way of doing this. Just group your radio buttons (those that need to be enabled/disabled) inside one update panel such that (in your .aspx code):



 <asp:UpdatePanel ID="GroupUpdateTheseRadioButtons" runat="server" UpdateMode="Always">
                        <ContentTemplate>
                              ....
                                           <tr>
                                              <td><asp:RadioButton ID="rbtn1" autopostback="false" runat="server" Text="bla bla bla1" GroupName="SendTo" CssClass="radiobtn"/></td>                                              
                                              <td><asp:RadioButton ID="rbtn2" autopostback="false"  runat="server" Text="bla bla bla2" GroupName="SendTo" CssClass="radiobtn"/></td>
                                           </tr>
                                   ...
                                  </ContentTemplate>
                                 </asp:UpdatePanel>



then your triggering control:


...

<tr>
                                             <td align="left"><asp:RadioButton ID="rbtnTRIGGER" autopostback="true" runat="server" Text="disableEnable" GroupName="TRIGGERGROUP" CssClass="radiobtn" Checked="True" oncheckedchanged="rbtnTRIGGER_CheckedChanged"/></td>


...


Then in your code behind (.aspx.cs)
  protected void rbtnTRIGGER_CheckedChanged(object sender, EventArgs e)


        {
            if (rbtnTRIGGER.Checked)
            {
               rbtn1.enabled=true;
               rbtn2.enabled=true;
            } 
        }





    About the Author

    The author have 12+ years experience in IT Industry with varying job roles from system developer/analyst/consultant positions. Majority of her development, implementation and systems support background focus on Financial/Banking/Credit Solutions.

    Archives

    November 2010
    October 2010

    Categories

    All

    RSS Feed