3

My preview works fine through Tridion UI and also through template builder.

When I publish the page I get the following error.

JScriptException: Expression 'RenderComponentPresentation()' had error 'Object reference not set to an instance of an object.'

I have this statement in my TBB.

 Tridion.ContentManager.Publishing.Rendering.Binary b = engine.PublishingContext.RenderedItem.AddBinary(file, "image.png", strGroup, name, "image/png");

I also do not get any error logs in Tridion events. But I have a warning like this.This warning ocurs as well in other environment also but still publish is success.

AddBinary was called with relatedComponent=null resulting in unmanaged binaries in Content Delivery. Please specify a related Component to prevent issues with (un)deploying binaries.

The same page is also getting published in another Tridion environment.

Can you suggest any reason for this.

8
  • Could you post your dwt code for your page layout? are you sure you're not running the preview for a different page, and when publishing another you are seeing this failure?
    – johnwinter
    Nov 22, 2013 at 15:21
  • @johnwinter. Thank you for posting. I am sure that preview for the same page only.
    – Patan
    Nov 22, 2013 at 15:30
  • they i think it's best you share some code for your dwt template :)
    – johnwinter
    Nov 22, 2013 at 16:24
  • @johnwinter. I do not have dwt code but I have c# TBB in a dll.:(
    – Patan
    Nov 22, 2013 at 16:38
  • 1
    Since it looks like it's a condition only happening when you're publishing, try attaching a debugger to tcmpublisher.exe and walk through your code... life saver!
    – Nuno Linhares
    Nov 22, 2013 at 17:28

1 Answer 1

6

There are (at least) three reasons why preview might succeed while publishing fails:

  • Your (c#) template code may use the RenderInstruction.RenderMode property to take a different action for preview and publish

  • Code which depends on assemblies in the GAC may fail if this assembly is only present on the CME server, not on the publisher server (this can only happen if you use a separate publisher machine)

  • The template code may fail in publishing if you made a change to an assembly (for instance one in the GAC) on the server very recently and haven't restarted the publisher service.

I hope this gives you some idea of where to look for a solution.

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.