Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know the error mentioned above will get explanation if I search in google,

But unfortunately, none of the solutions worked for me.

I think its some permission issue

My code is working fine locally,but when upload to server will show this error

Server : Windows Server,Service Pack 1

IIS : IIS 7

My Code to open a word document,edit it and then save

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Office;
using Microsoft.Office.Interop.Word;
using System.Net;
using System.IO;
using System.Text;
using System.Threading;

public partial class Admin_Download : System.Web.UI.Page
{
    CCWordApp test = new CCWordApp();

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void LinkButton30_Click(object sender, EventArgs e)
    {
        try
        {

            test.Open(@"D:\test.doc");
            test.InsertText("Today is a holiday");
            test.SaveAs(@"D:\test.doc");
            test.Quit();

        }
        catch (Exception ex)
        {
            TextBox1.Text = ex.Message;
        }

    }


}


Error Showing


Server Error in application /.
 
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.
 
Description: An unhandled exception occurred during the execution of the current web. Please review the stack trace for more information about the error and where it originated in the code.
 
Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.
 
ASP.NET does not have permission to access the requested resource. Try access rights to the resource to grant the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE} \ ASPNET on IIS 5 or Network Services on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity of the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
 
You can grant ASP.NET access to a file by right-clicking on the file in Explorer, Properties and select the Security tab. Click Add to select the user or group to add. Highlight the ASP.NET account, and check the boxes for the desired access.
 
Source Error:
 

Line 10: public class CCWordApp
Line 11: {
Line 12: public Word.ApplicationClass oWordApplic Word.ApplicationClass = new (); / / a reference to Word application
Line 13: public Word.Document oDoc = new Word.Document ();
Line 14: public CCWordApp ()
 
Source File: e: \ Websites \ DDPPortal \ App_Code \ CCWordApp.cs Line: 12
 
Stack Trace:
 

[UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.]
   CCWordApp .. ctor () in E: \ Websites \ DDPPortal \ App_Code \ CCWordApp.cs: 12
   Admin_Download .. ctor () in E: \ Websites \ DDPPortal \ Admin \ Download.aspx.cs: 15
   ASP.admin_download_aspx .. ctor () in c: \ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ Temporary ASP.NET Files \ root \ 8ad6eae3 \ a1c8e081 \ App_Web_yjjwtzfk.2.cs: 0
   __ASP.FastObjectFactory_app_web_yjjwtzfk.Create_ASP_admin_download_aspx () In c: \ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ Temporary ASP.NET Files \ root \ 8ad6eae3 \ a1c8e081 \ App_Web_yjjwtzfk.6.cs: 0
   System.Web.Compilation.BuildResultCompiledType.CreateInstance () +32
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath (Virtual Path virtual path, type required base type, HttpContext context, Boolean allowCrossApp, Boolean noAssert) 119
   System.Web.UI.PageHandlerFactory.GetHandlerHelper (HttpContext context, String request type, VirtualPath virtual path, physical String path) +33
   System.Web.UI.PageHandlerFactory.GetHandler (HttpContext context, String request type, virtual String path, String path) 37
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute () 307
   System.Web.HttpApplication.ExecuteStep (IExecutionStep step, Boolean & completedSynchronously) 155
 
Version Information: Microsoft. NET Framework Version: 2.0.50727.3603; ASP.NET Version: 2.0.50727.3614





Could anyone help me? or how can I solve this
Any help will be thankfull.



Kishore
Posted
Updated 7-Mar-13 21:10pm
v2
Comments
Thomas Daniels 8-Mar-13 2:44am    
Hi,

Your error is in Dutch. The language of this site is English, so I don't think many people will understand the error.

Uw error is in het Nederlands. De taal van deze site is Engels, dus ik vrees dat weinig mensen de error zullen begrijpen.

CodeProject has more English users than Dutch users, so it might be a good idea to translate the error message to English before posting it.

I believe the answer lies in the fourth and fifth paragraphs of the error message:
ASP.NET does not have permission to access the requested resource. Try access rights to the resource to grant the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE} \ ASPNET on IIS 5 or Network Services on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true">, the identity of the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

You can grant ASP.NET access to a file by right-clicking on the file in Explorer, Properties and select the Security tab. Click Add to select the user or group to add. Highlight the ASP.NET account, and check the boxes for the desired access.


If you have local admin rights on your dev machine or used the same account for creating the Word doc and running ASP. On the server, you typically use an account with only the necessary permissions to run the websites/webservices. Find out which account you use on the server and give that account the necessary permissions.
 
Share this answer
 
Comments
kishore Rajendran 8-Mar-13 3:13am    
Yes,but how can we grant access/ permission?could you explain ?I have little knowledge on that
BotCar 8-Mar-13 3:31am    
I don't think I can make it any clearer than the error message you posted makes it:

"You can grant ASP.NET access to a file by right-clicking on the file in Explorer, Properties and select the Security tab. Click Add to select the user or group to add. Highlight the ASP.NET account, and check the boxes for the desired access."
kishore Rajendran 8-Mar-13 4:46am    
ok Thanks
Namith Krishnan E 11-Jun-14 0:13am    
Did u get the solution.I have the same issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900