I'm developing a custom SPWebEventReceiver for SP2013 the declarative way using the following elements.xml file:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers Scope="Site">

I'm attaching this receiver under certain circumstances using:


Now I'm wondering where to define the GUID for the event receiver in elements.xml so that I can identify it programmatically later?

I've found several examples to do the whole process of defining the receiver programmatically like:

Guid guid = new Guid("...");
SPEventReceiverDefinition def = web.Site.EventReceivers.Add(guid);
def.Name = "MyWebProvisionedReceiver";

To sum it up: What is the "elements.xml way" for new Guid(...)?

1 Answer 1


Receiver child element in the Elements file don't support any Attribute or Child Elements for specifying GUID.


  • So I'll will do the whole process via code just to get a GUID I want to define myself. Thanks for your answer, Amal ... and thank you, Microsoft ;-)
    – jcp
    Nov 6, 2014 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.