Help with error message

  • I feel like a rookie with this question, but just can't seem to get it to work.

    I also know it's a setting, just can't seem to figure out how to 'set' the setting.

    I'm trying to work with a Word app (for mail merge) via ASP.NET and VB.NET. I get to this line:

    <FONT size=2>

    wrdApp = </FONT><FONT color=#0000ff size=2>New</FONT><FONT size=2> Word.Application</FONT>

    <FONT size=2><FONT size=3>And then I get to this error message:</FONT></FONT>

    <FONT size=2>Description: <FONT face=Arial>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.

    </FONT>Exception Details: <FONT face=Arial>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.</FONT></FONT>

    I know what you are going to say, "just do what the error message said with the Security setting and it will work."

    I have, via Windows Explorer and IIS Manager, navigated to the Bin folder, right clicked, selected the Security Tab and given ASPNET user (and every user) Full Control on the file Interop.Word.dll (and the bin folder itself). I still get this error message.

    Anyone had this and got it to work?



    <FONT size=2><FONT face=Arial></FONT> 


  • just do what the error message said with the Security setting and it will work.

  • Man, good prediction! You are like Nostradamus!

    You even got the capitalization correct!

  • I so knew that was coming 🙂

  • Isn't the solution obvious?

    Everything tastes better with XML.

  • I've found that you sometimes need to add permissions for the "NetworkService" account ase well.

  • @Albatross said:

    I've found that you sometimes need to add
    permissions for the "NetworkService" account ase well.

    I have found this to be true when doing direct platform-invoke calls into a non-COM DLL from ASP.NET as well. Worth a shot.

  • You should use a utility called FileMon.exe to find out what resource you actually need access to.  It may be as simple as granting read/write access to the Windows\Temp folder or some other 'temporary' folder location.  Just google filemon.exe to find it. Rarely have I found that access exceptions have a good enough explanation as to what 'really' needs to be fixed!

    Good luck!

  • Try giving the account permission to c:\program files\microsoft office\office11\ or wherever the actual word DLL is.

  • Givining permission to the bin file isn't going to be sufficent -- as a pratical matter, you'll need to give ASPNET user permissions to run Microsoft Word, and probably more than that besides.  For example, it wouldn't suprise me in the slightest to discover that there are three or four .DLLs that you need to grant permissions to in the system32 directory in order to make Word start up properly.  It sounds like the filemon will enable you to work out (eventually!) which files you need access to.

    Of course, the real question is "How long will you with the 'minimum security privilages' model (by adding permissions one file at a time to ASPNET) before you give up and grant ASPNET local adminstrator privilages, security be dammed?" 🙂

  • What you probably need to do is use the Microsoft .NET Framework X.X Configuration MMC snapin. It's in the Control Panel, under Administrative Tools.

    That's where you can mess with things like Code Access Security, which is what I suspect is keeping you from doing what you want. Of course, I have very little experience with it, so you should probably hit up Google for Code Access Security and Office and Word and see if you see anyone with similar problems.

Log in to reply

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.