Tuesday, March 13, 2012

System.Security.SecurityException: Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDEN

Hi
ACtually I am using the foolowing code
Line 22: Line 23: f3 = New Scripting.FileSystemObjectLine 24: f4 = f3.OpenTextFile(server.MapPath("visitor.txt"), 2)Line 25: f4.Write((session("hits")))Line 26: session("lock") = 1

when I was running, it is giving the following error, please help me out asap
Description:The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details:System.Security.SecurityException: Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED).

Thanks and Regds
Sasikumar N
Systems AnalystTry:
f4 = f3.OpenTextFile(server.MapPath("visitor.txt"), 1)
Unless you've set up some unique permissions, by default the web project runs under the ASPNET user which by default does not have write access. You are attempting to open a file in write mode...changing to 1 opens it in read mode only. Alternatively, give ASPNET user write permissions on that directory.
What trust level are you running your app in? My first instinct is that Server.MapPath isn't allowed because of your trust level. Even in medium trust you should be able to do FileIO in your own vdir. You can replace your server.MapPath call with something like:
Path.Combine( Request.PhysicalApplicationPath, "visitor.txt" )
Let me know if that solves the problem, if it's still broken, I'll help you investigate further.
--
Danny

0 comments:

Post a Comment