Using SP 2010, we created a content type with an event receiver bound to the content type. The ER is an ItemDeleting ER that prevents deletes from the library. When we create a library and attach the content type, the event receiver is successfully attached to the library (we use SP Manager to confirm the event receiver is attached to the Event Receiver node in SP Manager), and it fires correctly preventing deletes - all is well.
However, during the course of things, we needed to delete the event receiver from a few libraries to perform some item deletes. We did so programmatically by finding the library and performing a delete of the ER. When done, we reattached the ER to the library directly using the SP object model, so the ER on the library is a direct association to the library and not via the CT.
Now we want to fix this so all the ER's are attached to the libs due to the CT binding, and not a direct bind on the library. We deleted the ER from the offending libraries, but now can't seem to get the ER bound to the CT to 're-attach' to the library. Using SP Manager, we see no ER in the ER node for the library, although the Content Type is still attached to the library. The users can delete items because no ER exists, even though the CT is still bound to the library (and the CT still has the ER bound to it as confirmed via SP Manager).
How can I get the ER bound to the Content Type to 're-attach' to the library? As a test, we can create a new library, use SP Manager and see no custom CT's or ER's bound to the library. Then add the CT to the library, and in SP Manager you can see the CT under CT node, and the ER under the ER's node. So it works as expected when we use the GUI to add the content type to a library, but with data in the library existing, we can't delete and re-add the CT or we'll lose data.
How can we programmatically get the CT's ER to re-attach to the library?