0

I created a custom Event Receiver using WSP builder, and in elements.xml file i have given the ID of list which i find in elements.xml of List definition of particular list.

I also activated the feature, but event handler isn't triggering, neither can i attach my code as symbols are not loaded, i tried attaching it to OWSTimer.exe.

here's the element.xml for the event handler feature

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListTemplateId="11021">
    <Receiver>
      <Name>AddingEventHandler</Name>
      <Type>ItemAdding</Type>
      <SequenceNumber>10000</SequenceNumber>
      <Assembly>ListEventReceiver, Version=1.0.0.0, Culture=neutral, PublicKeyToken=gfhfghfghfghgfhgfh</Assembly>
      <Class>ListEventReceiver.ListEventHandler</Class>
      <Data></Data>
      <Filter></Filter>
    </Receiver>
  </Receivers>
</Elements>

List's element.xml file is

   <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <ListTemplate
        Name="listnamefolder"
        Type="11021"
        BaseType="1"
        OnQuickLaunch="FALSE"
        SecurityBits="11"
        Sequence="110"
        DisplayName="$Resources:ListFeatures,CL_ListDisplayName;"
        Description="$Resources:ListFeatures,CL_ListDescription;"
        Image="/_layouts/images/itdl.gif" />
</Elements>

Answer

I was assigning a DateTime Parameter to a String without converting it, which was throwing the error and didn't let w3wp.exe to load the event handler.

I recommend everyone to use Microsoft ULS Viewer for debugging

3
  • 1
    Unless the adding is happening in a timerjob you should not attach to OWSTimer, if you're adding though the UI you should attach to w3wp.exe. Anything in ULS log? Jul 25, 2012 at 19:01
  • Just added ULS Log Viewer, but there are so many things happening in a second, how would I know what is wrong, or do I have to go through all of them Jul 26, 2012 at 8:12
  • I downloaded Microsoft ULS viewer and its telling me the exact error, which I am about to solve thanks alot :D Jul 26, 2012 at 8:19

1 Answer 1

1

I would try multiple things:

  1. Add "Synchronous" to your event -just to avoid issue with multiple threads being spawn and makes it easier to debug.
  2. Use any tool such as Events Manager (http://speventreceiverman.codeplex.com/) or the SharePoint Manager to actually check that once your list is created you do have the handlers attached.
  3. Assuming that is attached, make sure you detach it as declarative attaching it, not sure that upon next deployment, simply the new one gets chained - this could also explain why even if successfully attached you are not getting the debugger to stop
  4. Finally - either attach your event handler to a Content Type (if you built your own custom list template, probably you also have a List Definition there, and you are 1 step away from having a content type used). If that is too much of a hassle, than at least, use code-based activation via the Feature Activation/Deactivation to attach/detach.

Hope this give you some tracks to follow!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.