In my 2011 Event System, I'm subscribing to two events:

EventSystem.Subscribe<Component, CheckInEventArgs>(OnComponentCheckedInPost, EventPhases.TransactionCommitted);
EventSystem.SubscribeAsync<Page, PublishEventArgs>(OnPagePublishPre, EventPhases.Initiated);

Inside OnComponentCheckedInPost method, I have code that creates a page, attaches the component presentation to it and then finally, calls the following method that publishes the page:

public static void PublishPage(IdentifiableObject item, PublicationTarget publicationTarget, bool rollBackOnFailure, bool includeComponentLinks, PublishPriority publishPriority)
    IEnumerable<IdentifiableObject> items = new List<IdentifiableObject> { item };
    IEnumerable<PublicationTarget> targets = new List<PublicationTarget> { publicationTarget };
    PublishInstruction instruction = new PublishInstruction(item.Session) 
        DeployAt = DateTime.Now,
        MaximumNumberOfRenderFailures = 5,
        RenderInstruction = new RenderInstruction(item.Session),
        RenderInstruction.RenderMode = RenderMode.Publish,
        ResolveInstruction = new ResolveInstruction(item.Session),
        ResolveInstruction.IncludeComponentLinks = includeComponentLinks,
        RollbackOnFailure = rollBackOnFailure,
        StartAt = DateTime.MinValue
    PublishEngine.Publish(items, instruction, targets, publishPriority);

Inside OnPagePublishPre, I have code that checks the publication title and and then executes some additional logic:

private void OnPagePublishPre(Page page, PublishEventArgs args, EventPhases phase)
    Publication publication = page.ContextRepository as Publication;
    if (publication != null) {
        if (publication.Title.ToLower == "my publication") {
            //Do something

Both events trigger fine on their own. If I create/save a component NOT inside "my publication", it creates the corresponding page and publishes it successfully. Similarly, if I publish an existing page INSIDE "my publication", it successfully fires the OnPagePublishPre method and executes the code.

The problems occurs when I create/save a component INSIDE "my publication" which creates and publishes the page, but DOES NOT trigger the OnPagePublishPre method. I have verified this by attaching to the TcmPublisher.exe and TcmServiceHost.exe processes and stepping through the code. I have also tried different options for the second event: Subscribe instead of SubscribeAsync, TransactionCommitted instead of Initiated and all possible combinations as well as the EventSubscriptionOrder.

After further research, I was able to find a solution by instead subscribing to EventSystem.SubscribeAsync<Page, SetPublishStateEventArgs>(OnPagePublishPre, EventPhases.Initiated) and then checking args.IsPublished to see if the page was published or unpublished.

However, I would still like to know how to trigger the original subscription (if possible) - for my use case, I don't care if the page is actually successfully published or not. All I need to know is that it was sent to publish in order to execute the business logic.

  1. Why is the PublishPage code not firing EventSystem.SubscribeAsync<Page, PublishEventArgs...;? Is there anything missing with this code?
  2. How is the 2011 event system working in this case? Does it have to do with the EventSubscription order or is there yet another subscription that I can use?

Even though I already have a solution, any insights are greatly appreciated.

  • So to get my head around this, basically you are saying that when you Publish a Page, your OnPagePublishPre is triggered, but it is not triggered by the PublishEngine.Publish(...) call in your PublishPage method? Aug 30, 2013 at 8:23
  • I think regardless the problem that you are having should be identified and fixed as the solution that you currently have of using SetPublishStateEventArgs will not work always. This event is triggered only when the publishing is successful. When you mention that creating/saving a component not inside "my publication" creates and page and publishes it, are you sure that the events are also triggered? You mention in the second case that is the publish an existing page inside "my publication " it triggers OnPagePublishPre not the earlier case.
    – Likhan
    Sep 2, 2013 at 7:17
  • Since you state in your comments on the answers you have solved this, could you post an answer of yourself with the details and accept that so we have a clear question and an accepted answer for future reference? Sep 4, 2013 at 7:40

3 Answers 3


After further debugging, the "PublishEventArgs" is indeed firing. I was able to finally see it by attaching to dllhost.exe and dllhost3g.exe processes.


Are these the only two custom events in the implementation? Have you checkedif there is anything in the event viewer. events registered are fired in the sequene mentionedin the cm config.if u have any other event sys them DLL pl remove those for debugging purposes and only keep this one

  • Why would other Event Handler DLLs interfere with debugging this one? Aug 30, 2013 at 8:31
  • 1
    May be there are other event system dlls which are throwing exceptions before this one gets fired. Aug 30, 2013 at 22:15
  • 2
    Yes, I tried to simplify my original question by not including the part about the additional DLL that was actually throwing the exception. After further debugging, the "PublishEventArgs" is indeed firing. I was able to finally see it by attaching to dllhost.exe and dllhost3g.exe processes. Sep 3, 2013 at 20:10

One of your methods is public, while the one that isn't firing is private. Did you try making it public as well?

  • None of the methods need to be public, as long as they are in the same class. The class extending TcmExtension needs to be public and the constructor of it of course. Aug 30, 2013 at 8:29
  • 1
    Yes, I agree, this is working fine without having to switch to public. Sep 3, 2013 at 19:46

Your Answer

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

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