Question

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">
    <Receiver>
      <Synchronization>Synchronous</Synchronization>
      <Name>MyWebProvisionedReceiver</Name>
      <Type>WebProvisioned</Type>
      <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
      <Class>Foo.Bar.Class</Class>
      <SequenceNumber>10000</SequenceNumber>
    </Receiver>
  </Receivers>
</Elements>

I'm attaching this receiver under certain circumstances using:

web.Site.EventReceivers.Add(
    SPEventReceiverType.WebProvisioned,
    Assembly.GetExecutingAssembly().FullName,
    "Foo.Bar.Class");

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";
...
def.Update();

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

Was it helpful?

Solution

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

http://msdn.microsoft.com/en-us/library/office/ms472893(v=office.15).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top