using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
namespace MSIT.Samples
{
class
Program
{
static
void Main(string[] args)
{
SPSite spSite = null;
SPWeb spWeb = null;
SPList spList;
try
{
spSite = new
SPSite("http://r2-basemachine:1111");
spWeb = spSite.OpenWeb();
spList = spWeb.Lists["Contacts"];
//spList = spWeb.Lists["ContactType"];
string asmName = "MSIT.ItemReceivers, Version=0.0.0.0, Culture=neutral, PublicKeyToken=6546c52e1a7f48a0";
string className = "MSIT.ItemReceivers.UpdateContactsEvent";
spList.EventReceivers.Add(SPEventReceiverType.ItemAdded, asmName, className);
spList.EventReceivers.Add(SPEventReceiverType.ItemUpdated, asmName, className);
spList.Update();
}
catch
{}
finally
{
spList = null;
spWeb.Dispose();
spSite.Dispose();
spWeb = null;
spSite = null;
}
}
}
} |