Thursday, 26 January 2012

Using GUID instead of class name

I will demonstrate on example of adding Event Receiver.

Create Event Receiver, open class file.
First add this:
using System.Runtime.InteropServices;

Then add this above class (use GUID Generator):
public class GoleszympansyEventReceiver : SPItemEventReceiver

Now, let's imagine you want to change class name or namespace. You'll have to change it also in Elements.xml.
But not anymore. Just insert this into elements.xml:

Guid here MUST be lower case. Just paste Guid from GUID Generator and then select it and press Ctrl+U.

Now the compiler will take care of the rest.

Full list of replaceable parameters can be found here:

No comments:

Post a Comment