1

I'm attempting to debug an event handler and on the breakpoint I get the message that no symbols have been loaded when attaching to process. Is there any way I can figure out why this is? The breakpoint should be hit every time the event handler is fired. On the other hand, is there another way to output errors within an event handler solution to get around this for now? As the log file I'm outputting to isn't being hit. Thanks

EDIT: Elements.xml (one event receiver out of two)

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListTemplateId="1230">
  <Receiver>
    <Name>CCL_CustomListEventsItemAdded</Name>
    <Type>ItemAdded</Type>
    <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
    <Class>PS.CCL_EventHandlers.CCL_CustomListEvents.CCL_CustomListEvents</Class>
    <SequenceNumber>10000</SequenceNumber>
  </Receiver>
  <Receiver>
    <Name>CCL_CustomListEventsItemUpdated</Name>
    <Type>ItemUpdated</Type>
    <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
    <Class>PS.CCL_EventHandlers.CCL_CustomListEvents.CCL_CustomListEvents</Class>
    <SequenceNumber>10000</SequenceNumber>
  </Receiver>
  </Receivers>
</Elements>
  • 1
    For debugging event receivers you need to attach to the OWSTIMER process – Robert Lindgren Nov 24 '14 at 9:36
  • is that in addition to w3wp.exe? I've tried both and it still states no symbols loaded – Matt Nov 24 '14 at 9:41
  • @RobertLindgren really, I don't think we need to attach timer process for debugging event receivers. – Nadeem Yousuf Nov 24 '14 at 9:43
  • 3
    @RobertLindgren, I just tested it. I created an itemadded event handler to an announcement list and was able to debug it without attaching the owstimer process – Nadeem Yousuf Nov 24 '14 at 11:07
1

its not hitting as its based on the older OWSTIMER!!!!

firstly deploy your solution. Once deployed goto your service in services.msc and look for your timer service to restart. on 2010 it looks like:

sharepoint 2010 timer service.

right click and select restart.

now your timer service would stop and restart loading the new changes or addition you have made you can now attach to the w3wp.exe and OWSTIMER.EXE, it should hit!

you can also write to a text file using this method:

create a file on c drive on the sharepoint server and name it debugFile.txt , once created rightclick and goto properties to change the security for users and make it have all access (read/write) permission.

now you can add this method into your code:

    //Function to write logfile on c
    public void WriteLog(string message)
    {
        using (StreamWriter writer = File.AppendText(@"c:\debugFile.txt"))
        {
            writer.WriteLine(message);
            // Update the underlying file.
            writer.Flush();
            // Close the writer and underlying file.
            writer.Close();
        }
    }

now you have the above you can add this anywhere you want so you can write to file:

WriteLog("test");

or like this for debugging:

try
{
     //code goes here
}
catch(Exception a)
{
     WriteLog("**************ERROR***************** 2" + a.Message + " " + a.StackTrace + a.Source + a.InnerException + Environment.NewLine);
}

like i said you need to restart the owstimer service everytime you update your solution.

EDIT

you should create the VS project using the template provided from VS!

http://msdn.microsoft.com/en-gb/library/ee231604(v=vs.110).aspx

as for your issue i think the link is missing as your symbols are now loading correctly!

your elements.xml should look somthing similar to this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListUrl="Lists/USER">
      <Receiver>
        <Name>UseritemAddedEvent</Name>
        <Type>ItemAdded</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>UseritemAddedEvent.UseritemAddedEvent</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>
  </Receivers>
</Elements>

as you can see the list url is looking for a list called USER within the site that this is deployed to.

its name is UseritemAddedEvent , you can name it anything more meningful ;), its type is the event type, assembly is obviously the assembly of the project so keep that the same clss is the namespace + class name together that is seperated by .

do this for each event type you add to the project!

an example is here:

http://msdn.microsoft.com/en-us/library/office/ms460929(v=office.15).aspx

as explained for two event types:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListUrl="Lists/CONTROLS">
      <Receiver>
        <Synchronization>Synchronous</Synchronization>
        <Name>controlsEventItemAdded</Name>
        <Type>ItemAdded</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>UseritemAddedEvent.controlsEvent.controlsEvent</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>
      <Receiver>
        <Synchronization>Synchronous</Synchronization>
        <Name>controlsEventItemUpdated</Name>
        <Type>ItemUpdated</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>UseritemAddedEvent.controlsEvent.controlsEvent</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>
  </Receivers>
</Elements>
  • have tried the above with no luck, the symbols are loaded when I create a new record but then after the record is entered nothing else happens – Matt Nov 24 '14 at 10:30
  • what events are you using? – Ali Jafer Nov 24 '14 at 10:34
  • also how did you create the event handler?? did you use VS template or create one yourself? – Ali Jafer Nov 24 '14 at 10:36
  • item added, item updated. Empty VS sharepoint project and added the event receivers in, (two, one for custom lists and another for task lists) – Matt Nov 24 '14 at 10:42
  • you should use the template that comes with visual studios under sharepoint msdn.microsoft.com/en-gb/library/ee231604(v=vs.110).aspx that way it does it all for you as you would need to ammend the elements.xml file properly – Ali Jafer Nov 24 '14 at 10:45
0

This is a common VS issue that we see usually. Make sure that you are attaching to the appropriate running instance of w3wp.exe while debugging. If the issue is still there, restart Visual Studio, clean-up, build and redeploy the Event Handler and then debug. Worked perfect for me.

  • I've attached it to all instances of w3wp.exe rebuilt, cleaned, reployed and no changes :/ – Matt Nov 24 '14 at 9:41
  • @Matt make sure you are doing a debug and not release build. Also try doing an IISRESET and then see if breakpoints are hit. Lastly, you can check whether your event handler is properly added by a tool like SPMAnager. – Nadeem Yousuf Nov 24 '14 at 9:45
  • definitely debug, how would I do an iisreset? and what would be affected? and I have activated the event handler in the site features, wouldn't this suggest that it's been added correctly? – Matt Nov 24 '14 at 9:51
  • Type iisrest at command prompt. It will stop/start the IIS. But as you may be doing it on dev server iisreset should not be a problem. – Nadeem Yousuf Nov 24 '14 at 11:10
  • iisreset or pool reset is a requirements. You won't be able to attach without it – Denis Molodtsov Nov 24 '14 at 12:58
0

The list template Id was incorrect. For some reason it was stated as '1230' which I'm still unsure to what that is but I've changed it to 100 and 107 respectively.

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.