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