I have a custom Umbraco event handler class, that deals with ApplicationStarted/Initialized/Starting events, a long with published events. It also sets up all my dependency injection for my controllers.
All of a sudden, none of the events are being hit. I was previously inheriting my class from IApplicationEventHandler, and the ApplicationStarted event was being hit correctly. However I changed the file to inherit from ApplicationEventHandler and now nothing is firing. I tried changing it back to IApplicationEventHandler but no use, now no events are firing at all.
I cant for the life of me figure out why none of the events have suddenly stopped firing. It's especially weird as previously they were firing fine.
Also, in my updated class, I have set breakpoints on all the methods, including the constructor, but it only ever makes it into the constructor, never the event methods.
@JustinMoser, you got me right on track. What got me was a line I had at the beginning of the class:
private UmbracoHelper Umbraco = new UmbracoHelper(UmbracoContext.Current);
After I moved that into my handler method, then it was happy and my events were fired. Only took me a few hours to troublehoot, so I'm documenting it here for sanity's sake.
ApplicationEventHandler events not firing.
I have a custom Umbraco event handler class, that deals with ApplicationStarted/Initialized/Starting events, a long with published events. It also sets up all my dependency injection for my controllers.
All of a sudden, none of the events are being hit. I was previously inheriting my class from IApplicationEventHandler, and the ApplicationStarted event was being hit correctly. However I changed the file to inherit from ApplicationEventHandler and now nothing is firing. I tried changing it back to IApplicationEventHandler but no use, now no events are firing at all.
My code below:
I cant for the life of me figure out why none of the events have suddenly stopped firing. It's especially weird as previously they were firing fine.
Also, in my updated class, I have set breakpoints on all the methods, including the constructor, but it only ever makes it into the constructor, never the event methods.
Btw, I am using umbraco v6.1.1.
Thanks, Justin
Turned out it was having a constructor that screwed it up...duh!
@JustinMoser, you got me right on track. What got me was a line I had at the beginning of the class:
After I moved that into my handler method, then it was happy and my events were fired. Only took me a few hours to troublehoot, so I'm documenting it here for sanity's sake.
Hi guys,
I am trying to inject dependencies in my custom Umbraco event handler class and I am using Simple Injector MVC for Dependency injection.
But I cannot figure out what I should because ApplicationStarted is not being hit during debugging.
when I remove the dependencies from constructor, it works. But I need such service to accomplish such task.
In Controllers, dependencies are working just fine but when I come to inject dependencies in this class, it is not working :/
Does anyone what I am missing please?
Thank you
Kind Regards
Hi Simon,
Have you managed to solve the problem? The dependency injection doesn't seem to work for ApplicationEventHandler, not even in the newest v 7.5.9.
It could be because the IoC code hasn't been fired yet.
I had several startup classes that all inherited ApplicationEventHandler. However you can't be sure of the order in which they're run.
is working on a reply...