I am trying to add an ItemAdded event receiver in a FeatureActivated event receiver (because it's a site scoped feature and apparently that means SharePoint will ignore anything I tell it and apply it to all lists on the site if I use XML to register it). So inside the FeatureActivated method in the Feature event receiver, I've added:
SPList list = web.GetList("/Lists/EmailQueue");
string assemblyName = typeof(EmailAddedEventReceiver.EmailAddedEventReceiver).Assembly.GetName().FullName;
string className = typeof(EmailAddedEventReceiver.EmailAddedEventReceiver).FullName;
list.EventReceivers.Add(SPEventReceiverType.ItemAdded, assemblyName, className);
I've debugged through it and the assembly and class name both look correct, and the count
property of list.EventReceivers
goes from 0 to 1. But when I try actually adding things to the list the receiver doesn't fire, and when I go into powershell and check for event receivers on lists it doesn't show any receiver registered to the list.
I have also tried adding list.update()
at the end, but that didn't help, as well as resetting OWSTIMER between deploys. I'm not even sure what else to try, or how to figure out what the error is.