I am having a problem with a scheduled job. The job is running fine when it's run manually, but when it's run on time automatic, I get an object reference not set exception. Any ideas?
privatestaticintTraverseXml(XmlDocument xmlDoc,PageReference importo,PageDataCollection children){PageTypeImportPageType=EPiServer.DataAbstraction.PageType.Load(SiteSettings.Settings.UnitPageTypeID);XmlDocument xmlDoc2 =newXmlDocument(); xmlDoc2.Load(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["ESsImportMappingsXML"]));Dictionary<string,string> propertyMappings =newDictionary<string,string>();foreach(XmlNode xmlnode in xmlDoc2.SelectNodes("/mappings/mapping")){ propertyMappings.Add(xmlnode.Attributes["key"].Value.ToString(), xmlnode.Attributes["pagekey"].Value.ToString());}int count =0;XmlNodeList nodes = xmlDoc.SelectNodes("/pages/page");foreach(XmlNode node in nodes){Utility.CreatePage(node, importo, children, propertyMappings,ImportPageType); count++;}
This exception is thrown because current context is inaccessible when a job is run by scheduler and HttpContext.Current is null.
You should find another way to load or resolve path to your resources.
I am having a problem with a scheduled job. The job is running fine when it's run manually, but when it's run on time automatic, I get an object reference not set exception. Any ideas?