1

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(...)?

1 Answer 1

1

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

1
  • 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.