Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All
I have a small issue here.Im actually trying to do a page count of word documents and it rilly works fine in the local envirnment.Then a shifted my project to server and the page count started giving me an error saying

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
Description: An unhandled exception occurred during the execution of the current web request. 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 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true">, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:


Line 386: Microsoft.Office.Interop.Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();//error in this line


How to resolve this issue.....
Posted
Comments
Sergey Alexandrovich Kryukov 29-Oct-12 16:59pm    
This constructor is valid. Did you forget to reference the assembly microsoft.office.interop.word.dll? It's done via ".NET" tab of the window "Add Reference".
--SA

1 solution

This can be done using Microsoft.Office.Tools.Word.Document.ComputeStatistics using Microsoft.Office.Interop.Word.WdStatistic.Pages parameter:
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document.computestatistics.aspx[^],
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.wdstatistic.aspx[^].

—SA
 
Share this answer
 

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



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