Hello, I've been trying to implement an event handler for the FileService event SavedTemplate (to make a log of template modifications). I'm following the documentation as closely as I can, but when I try to add my handler to the savedTemplate property of the FileService class, I get a
No overload for "my_handler" matches delegate TypedEventHandler
using System.Web.UI;
using Umbraco.Core;
using Umbraco.Core.Services;
namespace Infrastructure.Events
{
public class UmbracoTemplateSavedHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
FileService.SavingTemplate += FileService_SavedTemplate;
base.ApplicationStarted(umbracoApplication, applicationContext);
}
private void FileService_SavedTemplate(IFileService sender, Umbraco.Core.Events.SaveEventArgs<ITemplate> e)
{
//Log template here
}
}
}
I don't really see anything in the docs that point to anything more concrete for what my method signature should look like. What am I missing here?
I found a naming collision (Umbraco.Core.Events wasn't working due to a namespace *.Umbraco.Template in my solution), but I fixed it and I'm still getting the delegate matching error when trying to assign the custom handler.
Yeah, that's identical to what I have (only difference is not fully qualifying the namespace for SaveEventArgs, which intellisense says it's getting the correct one).
Still getting the "no overload matches the delete" error on the FileService.SavedTemplate assignment when I'm calling it in an override for ApplicationStarted.
FileService event handlers
Hello, I've been trying to implement an event handler for the FileService event SavedTemplate (to make a log of template modifications). I'm following the documentation as closely as I can, but when I try to add my handler to the savedTemplate property of the FileService class, I get a
I don't really see anything in the docs that point to anything more concrete for what my method signature should look like. What am I missing here?
Hi,
not 100% sure what you have (the forums have messed the code up a bit).
but your register event should look like this.
with you're handler function looking like this :
You can see this in how uSync tracks template changes here : https://github.com/KevinJump/uSync/blob/v4_master/Jumoo.uSync.BackOffice/Handlers/TemplateHandler.cs#L108
I found a naming collision (Umbraco.Core.Events wasn't working due to a namespace *.Umbraco.Template in my solution), but I fixed it and I'm still getting the delegate matching error when trying to assign the custom handler.
Yeah, that's identical to what I have (only difference is not fully qualifying the namespace for SaveEventArgs, which intellisense says it's getting the correct one).
Still getting the "no overload matches the delete" error on the FileService.SavedTemplate assignment when I'm calling it in an override for ApplicationStarted.
Updated the OP with a better code example.
is working on a reply...