I have this piece of code below which I am using to publish to the web database. I am having an issue where when I publish with the code below I have a corrupt item in the web database which when I click on gives me the error 'Value cannot be null. Parameter name 'item''. When I look at the item the icon for it is that of the standard template vs the custom template which has a custom icon. But when I click on it I saw all the fields and also the above mentioned error.
Could having an item with the same name as the published item in the web database be an issue?
using (new SecurityDisabler())
{
Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");
Sitecore.Data.Database target = Sitecore.Configuration.Factory.GetDatabase("web");
Sitecore.Data.Items.Item home = master.GetItem(new ID(id));
Sitecore.Data.Database[] targetDatabases = { target };
Sitecore.Globalization.Language[] languages = master.Languages;
bool deep = false;
bool compareRevisions = true;
Sitecore.Publishing.PublishManager.PublishItem(home, targetDatabases, languages, deep, compareRevisions);
}