4

I am trying to implement a very basic event system example in tridion 2011 sp1. I have followed below steps.

  1. Created a class library project. Here is my code

    [TcmExtension("TridionEventSystemTest")]
    public class TestEvent : TcmExtension
    {
        public TestEvent()
        {
        Subscribe();
        }        
    
        public void Subscribe()
        {    
            EventSystem.Subscribe<Component, DeleteEventArgs>    (OnComponentDeletePre,EventPhases.TransactionCommitted);
        }
    
        private static void OnComponentDeletePre(Component com, DeleteEventArgs args, EventPhases phases)
        {
            string source = "custom event system";
            string message = "custom event handler has been executed successfully";
            if (!EventLog.SourceExists(source))
                EventLog.CreateEventSource(source, "Application");
            EventLog.WriteEntry(source, message);
            EventLog.WriteEntry(source, message, EventLogEntryType.Warning, 234);
        }
    }
    
  2. I did shut down iis, com+ services, tridion content manager service host

  3. Copied the class library project dll
  4. Added extension in tridion content manager config
  5. Restarted all the above services

When I delete a component in CMS I can see the below message in event viewer

TCM Extension initialized: TridionEventSystemTest (TridionEventSystem.TestEvent)

Component: Tridion.ContentManager Errorcode: 0 User: NT AUTHORITY\NETWORK SERVICE

I can not see any other message related to event system in event viewer. So I think my event handler is not getting called even when TCM Extension is initialized.

Please help,

5
  • What is EventLog? Commented Jul 22, 2014 at 9:26
  • EventLog will log message to windows event viewer
    – Mehedi
    Commented Jul 22, 2014 at 10:13
  • 1
    Maybe that's what isn't working?
    – Ant P
    Commented Jul 22, 2014 at 10:47
  • Why not try to log something in the TestEvent constructor to check that it does indeeed get initialized and that it can log succesfully.
    – Jan H
    Commented Jul 22, 2014 at 11:11
  • Thanks Jan ..Now i am able to create file on disk ..but if there is any run time error in my event system code,then nothing works until i restart the server. Is there any other way out?
    – Mehedi
    Commented Jul 23, 2014 at 13:49

2 Answers 2

8

You see event viewer message that your extension was initialized, so no problem here. However, it might be the case that you (NETWORK SERVICE) don't have rights to write to event log, or your code is just wrong. I would suggest trying something simpler, like creating a file on the hard drive, or just throwing exception. This way you will at least know that your code was executed.

3
  • Thanks ..I even tried with creating a simple text file. But nothing gets created ..It seems handler method is not getting called.
    – Mehedi
    Commented Jul 22, 2014 at 13:49
  • Try to reboot.. Commented Jul 22, 2014 at 14:51
  • Tried reboot also, nothing helps..can some body please tell me how TCM Extension gets initialized and handler gets called once event is fired in CMS..Apart from this I got some more log from event viewer related to Event System ..The COM+ Event System detected a bad return code during its internal processing. HRESULT was 80070057 from line 65 of d:\w7rtm\com\complus\src\events\tier1\subscription.cpp. This warning may be expected if the computer is low on resources. If the computer is not low on resources, and these warnings persist, it may indicate a problem in the COM+ Event System.
    – Mehedi
    Commented Jul 23, 2014 at 7:25
2

Did you verified that there is no dependency on any DLL other than your Event System DLL. If it is, you may need to place it in Tridion bin directory or may be need to register in GAC.

For Example: The EventLog class is a part of same assembly or some other assembly? Just in case this class or any of its member is in some other assembly or any of its member is using some other DLL to write log to Event Logs, then you may need to take care of that dll as well by registering in the GAC on CMS server.

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.