I have a Sitecore 8.1 CD instance. I also have some code that needs to create a content item in the Master database. (I am aware that is a no-no but I just need to figure this out at the moment) When my code attempts to use Glass Mapper to create a content item I get an error. Here is the code snippet and the error message. I am just trying to understand what the error means. I have a sense that this is simply a configuration problem. This code works fine on our Sitecore CM server. So I am hoping that by simply adjusting the config on our CD server I can get this to work. So far I have re-enabled the Master entry in ConnectionStrings.config and in Sitecore.config. But that hasn't fixed this.
SitecoreService service = new SitecoreService("master");
SimpleAes aes = new SimpleAes();
using (new SecurityDisabler())
{
Item parentItem = Factory.GetDatabase("master").GetItem("/sitecore/content/Non Page Content/Account Information/Shipping Addresses");
newAddress = service.Create(parentItem, newAddress); //THIS IS WHERE THE CODE FAILS
user.Addresses.Add(newAddress);
Utility.PublishItem(service.ResolveItem(newAddress));
id = aes.EncryptToString(newAddress.Id.ToString());
user.Addresses = user.Addresses;
user.Save();
}
Error Message:
Glass.Mapper.MapperException: Failed to find configuration for parent item type Sitecore.Data.Items.Item ---> System.NullReferenceException: Object reference not set to an instance of an object. at System.Object.GetType() at Glass.Mapper.Context.GetTypeConfiguration[T](Object obj, Boolean doNotLoad, Boolean checkBase) at Glass.Mapper.Sc.SitecoreService.Create[T,TK](TK parent, T newItem, Boolean updateStatistics, Boolean silent) --- End of inner exception stack trace --- at Glass.Mapper.Sc.SitecoreService.Create[T,TK](TK parent, T newItem, Boolean updateStatistics, Boolean silent)