1

Running VS and SharePoint on the same server, but I am unable to debug my simple Event Receiver to see why it is not firing.

Here is the snipp:

public class EventReceiver1 : SPListEventReceiver
{
    /// <summary>
    /// A list was added.
    /// </summary>
    public override void ListAdded(SPListEventProperties properties)
    {
        base.ListAdded(properties);

        TestReceiver(properties.WebUrl, properties.ListId);
    }

    protected TestReceiver(string webUrl, Guid listGuid)
    {
        using(SPSite site = new SPSite(webUrl))
        {
            using(SPWeb web = site.OpenWeb())
            {
                SPList list = web.Lists[listGuid];
                list.Description = "Test";
                list.Update();
            }
        }
    }
}

Solution deploys successfully, but going back to the UI and adding a list, description is not updated as seen in the TestReceiver() method. Attempting to attach VS to all w3wp process does not load any breakpoints either. What gives?

EDIT

I have also confirmed via Powershell, that the document library does have my Event Receiver attached to it.

8
  • are you using sp2010 w/ .NET 3.5? Commented Oct 16, 2015 at 21:34
  • @Colbs SP2013 w/ .NET 4.5
    – KidBatman
    Commented Oct 16, 2015 at 21:36
  • Have you ever gotten it to break? Like on the first deploy maybe? Commented Oct 16, 2015 at 21:41
  • @Colbs no not once to my recollection. To be honest, I don't even think the ER is firing. I added a try-catch to reach out and log to a DB, but nothing has been logged and the description of the list is never updated.
    – KidBatman
    Commented Oct 16, 2015 at 21:45
  • hmm, worked for me using ListAdding. Can you update the description in that event? Commented Oct 16, 2015 at 21:55

2 Answers 2

0

Re-deploying event receivers will sometimes continue to point to an old version. You may have tried some of these but here's how I would troubleshoot:

  1. Download SP Manager and drill down to the List where the Event Receiver is attached. You can remove / delete it manually.
    • use Powershell to remove the Event Rece3vier
    • Make sure you are attaching all W3WP Processes (From all Users)
    • Manually deploy the .dll to the GAC
    • Do a Full Retract / Install w/ Powershell (not VS)
    • IIS Reset
    • If all that fails, create a new list and new Event Receiver
3
  • A couple questions. Manually deploy the .dll... are you talking about physically dropping the .dll into the GAC or the old school stsadm way? Do a full Retract/Install... Are the Deploy/Retract options given through VS not sufficient for development of ERs?
    – KidBatman
    Commented Oct 16, 2015 at 21:59
  • You may have to use GACUtil.exe or manually navigate to GAC_MSIL to delete it. On rare occasions, Powershell will deploy things that VS cannot Commented Oct 19, 2015 at 17:15
  • I had tried all still Its not working Commented Aug 31, 2016 at 11:34
0

Use

protected void TestReceiver(string webUrl, Guid listGuid)

instead of

protected TestReceiver(string webUrl, Guid listGuid)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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