I use Sharepoint 2007 and I just try to use the Configuration Manager in a ItemAdded event that is attached to a list. I run this code:
IServiceLocator serviceLocator = SharePointServiceLocator.Current;
IHierarchicalConfig _config = serviceLocator.GetInstance<IHierarchicalConfig>();
string test =_config.GetByKey<string>("MyKey", ConfigLevel.CurrentSPWebApplication);
And on the last line I receive an error that the SPContext is null. The error come from the constructor of SPWebAppPropertyBag class:
this.webApplication = SPContext.Current.Site.WebApplication;
'Object reference not set to an instance of an object.'
In fact, the SPContext.Current is null... but in the ItemAdded function the context is not null... how to pass it to the constructor ?
Thanks a lot....