PdfDistiller COM object says "Access denied"

Have Acrobat installed.  Am trying to write an .eps file to a pdf file using the distiller com object.  The code is in a .net aspx page and  fails on this dim statement:

Dim AcroDist As New ACRODISTXLib.PdfDistiller

The error message is an access denied error.  See "=====" below for the aspx auto generated error.  

Am not impersonating.  I've tried giving the asp_net, iis_usr, network services accounts read, write and execute privileges on the c:\program files\adobe, c:\inetpub\wwwroot\pm2 (the application directory), and C:\temp directories but with no success.  I've also checked to make sure that the com object is referenced in my project.  

When I check my event log it says,

Access denied attempting to launch a DCOM Server. The server is:

I checked the registry and sure enough this is the pdfdistiller com object.  It was after looking at the event log that I added the NETWORK SERVICE acount's  read, write and execute permissions to the c:\program files\adobe directory.  As mentioned previously, this had no effect.

What do I need to do to get the com object to run?

Access is denied.
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: 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.

Source Error:

Line 98:
Line 99:         'create the distiller object
Line 100:        Dim AcroDist As New ACRODISTXLib.PdfDistiller
Line 101:        AcroDist.bShowWindow = False
Line 102:

Source File: c:\inetpub\wwwroot\PM2\PM2_pdf.aspx.vb    Line: 100

Stack Trace:

[UnauthorizedAccessException: Access is denied.]
   PM2.PM2_pdf.MakePdf(Object PMFormNo) in c:\inetpub\wwwroot\PM2\PM2_pdf.aspx.vb:100
   ASP.PM2_pdf_aspx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) in c:\inetpub\wwwroot\PM2\PM2_pdf.aspx:20
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   System.Web.UI.Control.Render(HtmlTextWriter writer)
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel Van Der WerkenIndependent ConsultantCommented:
Enable impersonation for this page and see if it solves the problem:

<identity impersonate="true" userName=""  password=""/>            
<identity impersonate="true" />
kdirkAuthor Commented:
Don't need to impersonate.

In IIS 6, the default account for the default application pool (of which this app is a member) is NETWORK SERVICES.  If I change the this default user to SYSTEM, the pdfdistiller COM object will run without error.  A filemon session indicated that vbc.exe was unable to create a directory in c:\winodws due to an access denied error.  In short SYSTEM has some privilege that I need to give to NETWORK SERVICES in either C:\WINDOWS or another directory that will allow the pdfdistiller com object to be instantiated.  I suppose it is possible that the COM object itself may require SYSTEM privileges.
kdirkAuthor Commented:
Worked on the problem by setting permissions on the dll directories, registry keys and more.  Spent hours with a MS tech.  No matter what we tried, couldn't get the com object to run on server 2003.  Instead, decided to use ghostscript 8.14 to create my pdf from a ps file.

Plan to do this by calling a .bat file from my .net app.

Bat file

@echo on

cd c:\

rem   enter the location of the ghostscript bin directory
SET GSBINDIR=C:\gs\gs8.14\bin

rem   enter the location of the ghostscript lib directory
SET GSLIBDIR=C:\gs\gs8.14\lib

SET GSSOURCE="C:\inetpub\wwwroot\au\docs\fa\pm2\ps\PM2Destination.ps"

SET GSDESTINATION="C:inetpub\wwwroot\au\docs\fa\pm2\pdf\PM2Form.pdf"

rem adjust the system path to include the ghostscript directories

rem and call PS2PDF to do the actual conversion

kdirkAuthor Commented:
Am using a win2k3 machine.  Tried several different approaches with system.diagnostics process, aspexec, stream reader.  Ended up doing this:

Public Sub LaunchBat()
        Dim WshExe

            WshExe = CreateObject("WScript.Shell")
            WshExe.Run("C:\inetpub\wwwroot\au\docs\fa\pm2\bat\createpm2pdf.bat", 3, 1)
        Catch ex As Exception
        End Try

    End Sub
PAQed with points refunded (125)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.