【发布时间】:2010-12-09 13:00:12
【问题描述】:
大家好。我正在尝试解决一个显然并不少见的问题,但我不确定如何为人们解决这个问题。当我通过 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 和 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。更好的解决方案将不胜感激。
【问题讨论】:
-
如已接受的答案中所述,处理此问题的方法原来是 StructureMap 中的代码更改。无需更改 IIS 配置。
标签: iis structuremap .net-3.5