0

I have created/bound an Event Receiver to a document library in Share Point 2010 to read the content of an excel file and load a list from the content.

Everything works well in development, I don't have access to the production servers so I logged a ticket to I.T deploy to production server (attaching the .wsp of ER).

The guy has deployed/activated the ER in the Production, Now I am not sure how to attach it to particular document library and how to validate if/when it is attached.

Ondrej Tucny
  • 27,626
  • 6
  • 70
  • 90
foo-baar
  • 1,076
  • 3
  • 17
  • 42
  • How did you do that in the development environment? What do you think is preventing you from doing the same in the production environment? – Ondrej Tucny Mar 21 '14 at 16:57
  • @OndrejTucny : While creating a Event Receiver in VS2010 at initial stages it asks you that which particular List/Document Library your want to attach the new ER to and thats how it gets attach there, but later I copied the .WSP from bin and get it deployed on production, now not sure how to attach it to Document Library. – foo-baar Mar 21 '14 at 17:13

2 Answers2

1
  1. If you used the VS2010 SharePoint templates and it asked you for a specific library, you probably have to modify it for your production library. In your VS solution look at the elements.xml file. You should see a at the top. If your Event Handler is scoped to web, you can change the "..." to the actual library name. Example: .

  2. Rebuild the WSP. Your support group should be running the add-spsolution and install-spsolution powershell commands to add it and install it to the farm.

  3. If you can get to the sub site in questions features (Site settings->Manage Site features) you should see your event handler present but deactivated.

  4. Click to activate it.

  5. Without server access (to see the logs in the 14 hive) it is tough to really see if it is attached. If your support team uses SharePoint Manager they can look to see if the handler is really attached to the library in question. Short of that, what I've seen people do is put a small chunk of code in their handler (item added/updated/etc.) that will update a status column on the library when it fires (e.g. "Handler Fired"). This way you can actually see if it is firing. Additionally, you could put any error message you might get in the code into this column (e.g. "Could not load file to list", etc.").

1

If with your WSP the dll that contains the event receiver is deployed in GAC on production then you can attach the event receiver to a list/library with powershell.

$type = "ItemAdding" #or any other type, like ItemDeleting, ItemAdded, ItemUpdating ...
$assembly = "YourAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5eff...(here goes assebly's token"
$class = "Your Class"

$list.EventReceivers.Add($type, $assembly, $class)

Source: http://naimmurati.wordpress.com/2012/03/22/add-modify-or-delete-list-event-receivers-with-powershell/

Naim Murati
  • 373
  • 1
  • 10