1

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 ?

2
  • 1
    Have you debugged the Resolver while unpublishing? Is it failing in your resolver code, or is it something else? Feb 10, 2015 at 14:05
  • 2
    The error occurs after the resolver has run. Actually, it only occurs when really unpublishing. When you open the unpublish dialog and select "show items to unpublish", the resolver also runs fine, and we don't get an error. The correct items to unpublish are shown Feb 10, 2015 at 14:10

1 Answer 1

2

After some more debugging, we found the problem.

Actually, there was a bug in our code which was fixed some time ago, but the resolver dll was not yet updated on the CM server.

The bug was in this line

ComponentTemplate template = context.Session.GetObject(new TcmUri(<TCMURI>)) as ComponentTemplate;

the tcm uri was not the uri of a component template, but of a publication. This resulted in the template object being null.

As a result, the code

resolvedItems.Add(new ResolvedItem(linkedArticle, template));

was adding a resolved item object with a specific component, and with a template set to null. This gave no problems when publishing, but apparently throws a null reference exception after the resolver has run when we are unpublishing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.