0

I am having problems with an Event Receiver made to target Picture Libraries (ListTemplateId="109" in Elements.xml). I have tried to follow the advice I have found online to no avail.

Check out is not enabled. I am disabling EventFiring in my code. Scope is set to web.

My code is adding text to the uploaded image like so:

public override void ItemUpdated(SPItemEventProperties properties)
   {           
       string fileName = properties.BeforeUrl;
       using (SPWeb web = properties.OpenWeb())
       {
           SPFile file = web.GetFile(fileName);
           string classification = properties.ListItem["Subject"].ToString();
           byte[] modifiedImage = AddSubjectToImage(file,classification);               
           this.EventFiringEnabled = false;
           file.SaveBinary(modifiedImage);
           this.EventFiringEnabled = true;
       }
   }

Any advice on this would be appreciated.

  • After disabling EventFiring, your event should not fire. Is it firing again? – Aanchal Jun 3 '14 at 13:57
  • I have not yet resolved this. I believe the problem has something to do with how the event receiver gets attached to the list. When I activated my feature it was working as intended on an existing library, but for newly created it will fire twice. So it seems like it the event receiver is registered twice. Any help would be appreciated! – SharePointMiller Jun 10 '14 at 6:41
  • You can delete them in SharePoint Manager, go to the list not the event receivers section, there is an event receiver section under the content types, right click the receiver and remove it. Verify with Sharepoint Manger. – Aanchal Jun 10 '14 at 6:45
  • Thanks, but I already checked how many event receivers are on the list, and only one is showing up. – SharePointMiller Jun 10 '14 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.