The PolicyInjector has not been set for the PolicyInjection static class. Set it invoking the Policy

来源:互联网 发布:js判断视频播放结束 编辑:程序博客网 时间:2024/06/03 17:32

EnterPrise Library 6.0提示如下错误:

The PolicyInjector has not been set for the PolicyInjection static class. Set it invoking the PolicyInjection.SetPolicyInjector method..


是因为EnterPrise Library 6.0改动了模块的功能类不再自动从Unity创建了,也就是引导也不依赖Unity容器组件,需要先使用静态方法注册一下

例如:使用Logging Application block模块

IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
Logger.SetLogWriter(logWriterFactory.Create());
使用Policy Injection Application block模块
PolicyInjector policyInjector = new PolicyInjector(configurationSource);
PolicyInjection.SetPolicyInjector(policyInjector);

使用Exception Handling Injection Application block模块
ExceptionPolicyFactory exceptionPolicyFactory = new ExceptionPolicyFactory(configurationSource);
ExceptionPolicy.SetExceptionManager(exceptionPolicyFactory.CreateManager());

参考博文:http://www.cnblogs.com/wintersun/archive/2013/05/10/3071246.html

0 0
原创粉丝点击