Having a bit of trouble with the events system when triggering an event via core service.
We have components saved to a publication that we need to copy across to another publication in the same instance of Tridion. These components are saved from a separate application that uses the core service.
So in summary: Create/update a component in webapp -> Save via core service to one publication -> Event system creates/updates copy in second publication.
We subscribe to the event using:
EventSystem.Subscribe<Component, SaveEventArgs>(Copy, EventPhases.TransactionCommitted);
We have a few configuration values stored in the Tridion.ContentManager.config file and access these using something similar to:
var configuration = ConfigurationManager.GetSection("custom.events") as NameValueCollection;
return configuration["Debug"];
The copy method works fine as manually opening the component in the interface and saving does exactly as expected. The config values are read in fine and the component gets copied across with all the correct content and metadata.
The event system falls over when we try to save a component externally using the core service. The errors we are seeing is as follows:
Object reference not set to an instance of an object.
StackTrace Information Details:
at Custom.EventsSystem.Configuration.Config.get_Debug()
at Custom.EventsSystem.Sync.Copy(Component component, SaveEventArgs args, EventPhases phase)
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Tridion.ContentManager.Extensibility.EventSubscription.DeliverEvent(IEnumerable`1 subjects, TcmEventArgs eventArgs, EventPhases phase)
This only happens when the save is triggered via the core service so I wonder if there is anything different in the way that Tridion reads the configuration file when accessed via the core service?
Would the better option be to have a separate configuration file separate to Tridion that we deal with manually?