Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have the following class:
public class MembershipEvents : ApplicationEventHandler
private IAtocMemberService _memberService;
private IIndiciaService _indiciaService;
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
_memberService = DependencyResolver.Current.GetService<IAtocMemberService>();
_indiciaService = DependencyResolver.Current.GetService<IIndiciaService>();
_memberService.MemberCreated += MemberService_MemberCreated;
_memberService.MemberUpdated += MemberService_MemberUpdated;
_memberService.MemberDeleted += MemberService_MemberDeleted;
private void MemberService_MemberCreated(IAtocMember member)
private void MemberService_MemberUpdated(IAtocMember member)
private void MemberService_MemberDeleted(IAtocMember member)
Inside one of my services i have:
public void OnMemberCreated(IAtocMember member)
if (MemberCreated != null)
and further down:
bool isCreated = _membersRepository.CreateMember(member);
this all used to work, we have made some code changes but not anywhere round here. So the event is raised and when i look at MemberCreated it is always null, even though it has been wired up . So it looks like there is no listener to the event.
One thing to note the services are registered using lightinject.
Anyone any ideas?
Ok fixed my issue. It was due to the way I was registering my service in the container. There was no lifetime scope set so it would have defaulted to request scope and hence the instance with the wired events was not the one that was passed into the other service.
Anyhow changing to :
container.Register<IAtocMemberService, AtocMemberService>(new PerContainerLifetime());
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted