你好。我试图解决一个显然并不少见的问题,我不知道如何找到解决问题的方法。当我通过IIS我的机器上运行StructureMap,我得到一个例外,它看起来像这样:StructureMap,IIS 7.5和FileIOException
**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标记为无限制访问...没有骰子。如果任何人有一些提示或链接,将不胜感激。
更新 所以没有办法,这是解决问题的最好方法,但周围挖掘和寻找到约书亚后面提到的,这些都是我必须做的就是它的工作的事情:StructureMap, Code Access Security and a Bad Solution to a Problem。更好的解决方案,将不胜感激。
正如在接受的答案中指出的那样,处理这个问题的方式是在StructureMap中进行代码更改。没有IIS配置更改是必要的。 – Mallioch 2009-10-25 14:55:58