Today I had some trouble registering an event receiver while provisioning a list instance in a site template. First I had a feature that defines a list template, a second feature that defines an event receiver for that template id and a site definition that activates both features and that contains a List-node to create a list instance the uses my list template.

Everything worked fine. The list was created, I could access the list, but my event receiver was not registered. I deactivated the feature that defines the event receiver and activated it again, and the registration of the event receiver was successful. But that was not an option. Why should we activate the feature in the site template and after creating a site deactivate and re-activate the feature?

To solve this issue, I created a third feature that creates the list instance. I modified the site template, removed the List-node and added the feature activation for the third feature.

Using this technique, the event receiver is registered to my list instance after the site is created using the site template.

So keep in mind, when you need to register an event receiver to a list in a site template, do not create the list in the onet.xml. Use a feature an a ListInstance-element instead.