Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Access Denied

9 views
Skip to first unread message

Deepankar Raizada

unread,
Oct 6, 2004, 2:01:05 PM10/6/04
to
Hi

In one of our ASP.NET Application web form we are using the
Microsoft.Office.Interop.Word COM DLL. We need to read some word documents
and create rtf files and merge them together into one doc file.

On click of a button the the word application com dll is getting activated,
but wehn we do this on a Windows Server 2003 machine we are getting the
following error.

Exception Details: System.UnauthorizedAccessException: Access is denied.

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

The COM DLL Microsoft.Word.Document has been given allow permission to the
ASPNET user account.

Can somebody help in setting the right permissions or finding a solution for
this.

This error in generated where the code has the following line
newApp = New Word.Application

Code:
Imports System.Runtime.InteropServices
Imports Word = Microsoft.Office.Interop.Word
Imports Office = Microsoft.Office.Core

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim newApp As Word.ApplicationClass

Dim source As Object = Server.MapPath("/site/Docs/" & sFileName)
Dim target As Object = Server.MapPath("/site/Docs/" & "temDocfile.rtf")

Dim unKnown As Object = Type.Missing

newApp = New Word.Application

newApp.Visible = True
newApp.Documents.Open(source, unKnown, unKnown, unKnown, unKnown,
unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown,
unKnown, unKnown)

Dim objformat As Object = Word.WdSaveFormat.wdFormatRTF

newApp.ActiveDocument.SaveAs(target, objformat, unKnown, unKnown,
unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown, unKnown,
unKnown, unKnown, unKnown, unKnown)

newApp.ActiveDocument.Close(unKnown, unKnown, unKnown)

newApp.Quit(unKnown, unKnown, unKnown)
newApp = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(newApp)
newApp = Nothing

End Sub

This code provided is for a testing page we had created where we are trying
to open a word document file and save that as a rtf file.

The folder where these files are opened from and closed have full
permissions to the ASPNet user account.

Thanks in advance
--
Warm Regards
Deepankar

Peter Torr (MS)

unread,
Oct 25, 2004, 2:17:45 PM10/25/04
to
"Deepankar Raizada" <Deepanka...@discussions.microsoft.com> wrote in
message news:02F95987-A7AC-4785...@microsoft.com...

> In one of our ASP.NET Application web form we are using the
> Microsoft.Office.Interop.Word COM DLL. We need to read some word documents
> and create rtf files and merge them together into one doc file.
>
> On click of a button the the word application com dll is getting
> activated,
> but wehn we do this on a Windows Server 2003 machine we are getting the
> following error.
>
> Exception Details: System.UnauthorizedAccessException: Access is denied.

HI,

Automating Office on the server is not supported, but this is probably a
DCOM activation issue:

http://support.microsoft.com/default.aspx?scid=kb;en-us;257757

Peter

--
Please post questions to the newsgroup - everyone benefits.
This post is provided "AS IS" with no warranties, and confers no rights
Sample code subject to http://www.microsoft.com/info/cpyright.htm
Office / Security / Random weblog -- http://weblogs.asp.net/ptorr


0 new messages