我在本地运行使用Visual Studio开发服务器在.NET 4.0 Web应用程序(内置在VS2010 web服务器),并在过去的几个月,我的StructureMap引导程序文件已完美运作。System.Security.SecurityException被扔在初始化StructureMap引导程序
我使用StructureMap 2.6.1
我并没有改变引导程序文件或Web.config文件,突然,试图启动我的Web应用程序时,我得到这个奇怪的错误。
这里被从网站上抛出的错误:
这是一个有点困难阅读。它说:
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.
Exception Details: System.Security.SecurityException. Request Failed.
这里是我的引导程序文件中的代码:
public class BootStrapper
{
public static void ConfigureStructureMap()
{
ObjectFactory.Initialize(x =>
{
x.AddRegistry<ProductRegistry>();
});
}
}
public class ProductRegistry : Registry
{
public ProductRegistry()
{
For<IFirmRepository>()
.Use<FirmRepository>().Ctor<string>("connectionString").Is(ConfigurationManager.ConnectionStrings["FeesAndFlows"].ConnectionString);
For<ICryptographyService>()
.Use<Rijndael>();
For<IUserRepository>()
.Use<UserRepository>().Ctor<string>("connectionString").Is(ConfigurationManager.ConnectionStrings["FeesAndFlows"].ConnectionString);
For<IAuthenticationService>()
.Use<AuthenticationService>();
For<ILogger>()
.Use<DatabaseLogger>();
}
}
错误正在对这一行抛出:
x.AddRegistry<ProductRegistry>();
我已经尝试添加每个这些线路到我的Web.config文件,一次一个,而他们并没有解决这个问题:
<trust level="Full" />
和
<securityPolicy>
<trustLevel name="Full" policyFile="internal"/>
</securityPolicy>
没有人有任何想法或可能听说过这样的问题吗?这是非常重要的,没有正确启动StructureMap的B/C,我的整个应用程序将不会运行。
谢谢, 迈克
UPDATE:
好了,看来我的问题是局部的。其他开发人员可以下载代码,并在本地机器上运行它。奇怪的。在调试模式下为我的web项目在本地运行时,它们引导StructurMap得很好,所有实例都解决了......
为什么只是我的机器不能引导StructureMap任何想法?
如何解锁Structuremap.dll? – Masoud