大家好。我正在尝试解决一个似乎很常见的问题,但不知道如何找到解决方案。当我通过IIS在我的计算机上运行StructureMap时,会出现异常,异常信息如下:
**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: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
这个问题在SO (https://stackoverflow.com/questions/784666/)、这篇博客文章的评论区(in the comments on this blog post),以及大约一年前在structuremap邮件列表上出现过(a year or so ago on the structuremap mailing list)。
我的问题不是在外国托管环境中运行它。我甚至不能让它在我的电脑上运行(IIS 7.5, Win7 RC, .NET 3.5)。我已经尝试配置网站使用自定义策略文件,并且FileIOPermission被标记为具有无限制的访问权限...没有用。如果有人有一些提示或链接,将不胜感激。
更新 所以这绝不是解决问题的最佳方法,但是在挖掘和研究Joshua提到的内容后,这些是我必须做的事情才能让它工作: StructureMap, Code Access Security and a Bad Solution to a Problem。更好的解决方案将不胜感激。