Error occured in updating SPEventReceiverDefinition
I have a another problem.I did above testing in my own computer.
When i really do to my site, the following error is occured.
First i install my assembly that contains my event class to the GAC.
I use the following code to add event to document library.
SPSite l_SPSite = new SPSite("http://mysharepointsite");
SPWeb l_SPWeb = l_SPSite.OpenWeb();
SPList l_SPList = l_SPWeb.Lists["Documents"];
string id = l_SPList.ID.ToString();
SPEventReceiverDefinition l_SPEvent = l_SPList.EventReceivers.Add();
l_SPEvent.Class = "ItemPermission.SPDocumentEventHandler";
l_SPEvent.Assembly = "ItemPermission,Version=1.0.0.0,Culture=neutral,PublicKeyToken=123770469bc80c2b";
l_SPEvent.SequenceNumber = 5000;
l_SPEvent.Type = SPEventReceiverType.ItemAdded;
l_SPEvent.Name = "CustomAddingEvent";
l_SPEvent.Update();//Error is happened here.
Error is :
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Thanks