Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

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,

share|improve this question
    
What is EventLog? –  user978511 Jul 22 at 9:26
    
EventLog will log message to windows event viewer –  user1137 Jul 22 at 10:13
1  
Maybe that's what isn't working? –  Ant P Jul 22 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 Jul 22 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? –  user1137 Jul 23 at 13:49

2 Answers 2

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.

share|improve this answer
    
Thanks ..I even tried with creating a simple text file. But nothing gets created ..It seems handler method is not getting called. –  user1137 Jul 22 at 13:49
    
Try to reboot.. –  user978511 Jul 22 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. –  user1137 Jul 23 at 7:25

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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