In our Tridion implementation (2013 SP1), we have built a custom resolver.
The resolver code is pretty simple, if we publish a component, and that component is of schema X, then also add all components added in a componentlinkfield to the published items
var publishedComponent = item as Component;
if (publishedComponent != null)
{
if (publishedComponent.Schema.Id.ItemId.Equals(<TCMURI>.ItemId))
{
ItemFields contentFields = new ItemFields(publishedComponent.Content, publishedComponent.Schema);
if (contentFields.Contains("articles"))
{
ComponentTemplate template = context.Session.GetObject(new TcmUri(<TCMURI>)) as ComponentTemplate;
ComponentLinkField linkedArticles = contentFields["articles"] as ComponentLinkField;
if (linkedArticles != null && linkedArticles.Values != null)
{
foreach (var linkedArticle in linkedArticles.Values)
{
if (resolvedItems.FirstOrDefault(r => r.Item.Id == linkedArticle.Id) == null)
{
resolvedItems.Add(new ResolvedItem(linkedArticle, template));
}
}
}
}
}
}
This is working fine when publishing - the item gets published, and all linked components get published as well.
However, when we unpublish a component of that specific schema, the resolver also runs well, but we receive a null reference exception a bit after that
The exception we get is
Object reference not set to an instance of an object.
Component: Tridion.ContentManager.Publishing
Errorcode: 0
User: NT AUTHORITY\SYSTEM
StackTrace Information Details:
at System.Object.GetType()
at Tridion.ContentManager.Publishing.Transporting.DefaultComponentHandler.HandleResolvedItemForUnPublishing(ResolvedItem resolvedItem)
at Tridion.ContentManager.Publishing.Transporting.TransportPackage.AddResolvedItemsForUnPublishing(ISet`1 resolvedItems)
at Tridion.ContentManager.Publishing.Handling.DefaultPublishTransactionHandler.HandlePublishRequest(PublishTransaction publishTransaction)
at Tridion.ContentManager.Publishing.Handling.DefaultPublishTransactionHandler.ProcessPublishTransaction(PublishTransaction publishTransaction)
at Tridion.ContentManager.Publishing.Publisher.QueueMessageHandler.HandleMessage()
Has anyone seen this error before ? Is there something specific we should do in our custom resolver ?