Hi there, I would like to be able to use ISettingManager during module PreInitialize (specifically, the web module). But I cannot figure out the appropriate way to inject it. Constructor or property injection seem to be out of the question, and I'm not sure how to inject the appropriate dependencies using IIocManager... I'm at an impasse.
Is it possible to use ISettingManager during module PreInitialize? If so, any hints? :)
2 Answer(s)
-
0
You can not use SettingManager in PreInitialize. Because, SettingManager is not registered and initialized in that point. It's usable in PostInitialize. SettingManager is not for startup configuration, it's for runtime configuration. So, to configure modules, use web.config and ConfigurationManager (for ASP.NET Core, use appsettings.json).
In general, to resolve dependencies using IocManager, see documentation: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Dependency-Injection#DocIocHelper">http://www.aspnetboilerplate.com/Pages/ ... cIocHelper</a> (so, you can just use IocManager.Resolve<YourService>();
-
0
That was a sufficient hint, thank you! I was able to achieve what I wanted in PostInitialize.