Code Project

Link Unit

Friday, January 29, 2010

Exception Details: System.Runtime.InteropServices.COMException: Access is Denied

"Access Denied" : Error was creeping when we are tring to load the crystal report file by using Load("~/Reports/MyReport.rpt"); The error looks silly as it is not pointing where the access should be given. After doing bit of googling and applying/reverting the changes found the solution.
Reason & Solution
When a CR[Crystal Report] is being created in ASP.NET, the .NET will create a report file in a temp folder, e.g. C:\Documents and Settings\MachineName\ASPNET\Local Settings\Temp.
#1 You can try to give ASPNET permission for this folder.
#2 You can also update web.config to impersonate.

<authentication mode="Windows">
<identity impersonate="true"
password="mypassword" />

I preferred the #1 solution ,as it is easier to give permissions once on the folder; You may like to try option #2 but keep a note that whenever Domain[very rare],user or password changes at that point web.config needs to be updated.

Hope it helps
Post a Comment