Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 1881

Request for the permission of type 'System.Security.Permissions.FileIOPermission failed

$
0
0

I'm writing a HTTPModule for Microsoft IIS. As part of the initalization callback function, it reads in a configuration file from disk. This has worked fine on one of our development environments, but on a newly created environment, we get the following error:

Server Error in '/' Application.


Security Exception
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.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException:Requestfor the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]System.Security.CodeAccessSecurityEngine.Check(Object demand,StackCrawlMark& stackMark,Boolean isPermSet)+0System.Security.CodeAccessPermission.Demand()+55System.Configuration.ConfigurationFileMap.GetFilenameFromMachineConfigFilePath()+77System.Configuration.ClientConfigurationHost.OpenExeConfiguration(ConfigurationFileMap fileMap,Boolean isMachine,ConfigurationUserLevel userLevel,String exePath)+44System.Configuration.ConfigurationManager.OpenExeConfigurationImpl(ConfigurationFileMap fileMap,Boolean isMachine,ConfigurationUserLevel userLevel,String exePath,Boolean preLoad)+112System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(ExeConfigurationFileMap fileMap,ConfigurationUserLevel userLevel)+50
abc..ctor()in C:\repos\myrepo\src\a\Configuration\MyConfig.cs:40def..ctor()in C:\repos\myrepo\src\a\MyModule.cs:48

The code that throws the error looks as follows

string config_path =ConfigurationManager.AppSettings["configPath"];
log.Debug("Config path: "+ config_path);ExeConfigurationFileMap configMap =newExeConfigurationFileMap();
configMap.ExeConfigFilename= config_path;System.Configuration.Configuration config =ConfigurationManager.OpenMappedExeConfiguration(configMap,ConfigurationUserLevel.None);

The trust level is set to "Full" on both servers and we have tried all sorts of combinations of file permissions on the file, so what could be causing this?


Viewing all articles
Browse latest Browse all 1881

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>