11

We are using Tridion 2011 SP1, We are facing error Unable to create an Eventsystem Object. As debugging is not working we have implemented custom logging. We found that Subscribe function is getting called, but OnComponentSavePre function is not getting called. Below is the code we have written

using System;
using Tridion.ContentManager.ContentManagement;
using Tridion.ContentManager.Extensibility;
using Tridion.ContentManager.Extensibility.Events;
using System.IO;

namespace TridionMetadataUpdateEvent
{
    [TcmExtension("Tridion2011EventSystem")]  
    public class EventSystem : TcmExtension
    {
        public EventSystem()
        {
            StreamWriter writer = File.AppendText(@"D:\data.txt");
            writer.WriteLine("Event Execution Started.");
            writer.Close();
            Subscribe();
        }

        public void Subscribe()
        {
            StreamWriter writer = File.AppendText(@"D:\data.txt");
            writer.WriteLine("Inside Subscribe.");
            writer.Close();
            try
            {
                EventSystem.Subscribe<Component, SaveEventArgs>(OnComponentSavePre, EventPhases.Initiated);
            }
            catch(Exception ex)
            {
                StreamWriter writer2 = File.AppendText(@"D:\data.txt");
                writer2.WriteLine(ex.Message);
                writer2.Close();
            }
        }

        private static void OnComponentSavePre(Component comp, SaveEventArgs args, EventPhases phase)
        {
            StreamWriter writer = File.AppendText(@"D:\data.txt");
            writer.WriteLine("Inside OnComponentSavePre.");
            writer.Close();
            //sample code we will be writting here
        }
    }
}
  • 1
    To debug, in the Visual Studio debug window, select the 'show processes from all users' and chose the one for dllhost that the MTSUser is running. You can find the process also in the processes list from The Task Manager and copy the PID number. If running in debug mode on the server it should step into the debugger. – robrtc Mar 20 '13 at 13:51
  • 2
    Unable to create an event system object is a COM error. You are probably enabling (or still have enabled) the Event in the MMC snap-in instead of using the new mechanism to register the event in code only. – Nuno Linhares Mar 20 '13 at 13:53
  • Thanks Nuno, Yes we had oncomponentsavepre event enabled in MMC snap in, after disabling it our code started working. – user1453602 Mar 20 '13 at 16:36
9

Check for the following: 1) IN Tridion Content Manager config file on CMS server, ensure that all correct EventSystem DLLs has been subscribed, there is no unwanted DLLs registered and the path of the desired even system dlls is correct

2) As Nuno suggested, check in SDL Tridion Configuration Manager, that older COM+ event system are not enabled

13

As Nuno commented, that error is about the old legacy VB event system. You can disable that if you are not using it and just have your new .NET assembly running instead (which doesn't require any further configuration).

I have no problems running and debugging that code (attaching to TcmServiceHost.exe) so the problem is likely that your extension hasn't been loaded.

Check for errors in the Event Viewer, double-check the path/assembly information in Tridion.ContentManager.config, and restart the Tridion Content Manager Service Host to make sure your new extension is being loaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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