1
使用Configuration Manager
我正在使用MVC4项目结构图,我尝试使用配置管理器中的ObjectFactory:Stucture地图中的ObjectFactory
public static IContainer Initialize() {
ObjectFactory.Initialize(x =>
{
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
var someConfiguration = ConfigurationManager.GetSection("someconfiguration") as SomeConfigurationSection;
});
return ObjectFactory.Container;
}
我有错:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: An error occurred creating the configuration section handler for someconfiguration: This method cannot be called during the application's pre-start initialization phase.
是有可能我无法在Object Factory中使用配置管理器?如果不是,有什么可能的方式来读取web.config的依赖注入purpouses?
P.S. 没有使用ObjcetFactory,ConfigurationManager工作正常。