0

enter image description hereI have created Visual Web Part which adds items to a X list.But while adding item to it, I am getting the following error once Item.update() hits in Visual studio . is it because of Event Receiver which fires while adding item ?. How to resolve this?

  • Hi Ashish, It would be good if you can tell what you are doing in the event recievers .I would also suggest you to look on the varaibales that you are using in your visual web apart. More details might help. – Arvi Apr 14 '14 at 4:52
  • I don't know exactly what event receiver is doing because it was coded by someone else.so not getting proper idea.just read somewhere that it might be because of event receiver. – SharePointMan Apr 14 '14 at 4:58
  • You were able to add items to list from Web interface ? – Arvi Apr 14 '14 at 5:00
  • yes adding item directly creates no problem at all – SharePointMan Apr 14 '14 at 5:00
  • 1
    Please provide the code so we can help.. – Arsalan Adam Khatri Apr 14 '14 at 5:14
1

It's hard to know exactly what your error is but it looks as though your event receiver is doing something to cause the event receiver to re-fire. This could be caused by, for example, adding an item to the list as part of the OnItemAdding event. Or, more insidiously (and this I have actually seen, as opposed to the first example which is pretty easy to catch during the normal debugging process), one person sets up an event receiver that adds to list A when an item in list B is added and then someone else comes in and sets up a second event receiver that adds to list B when something is added to list A. Either way (or some alternative permutation of these ways), something is happening to cause an infinite loop of list item updates. IME .NET actually tends to find potential stack overflows before they do a ton of damage, so hopefully you don't have several thousand invalid list items added in as a result of this.

If you're lucky you can just turn off the event receiver in question and perhaps find a way to replicate its functionality elsewhere. If not, you may have to figure out an alternative method of adding your information yourself. From an administrator's perspective, this is precisely why one needs to stay abreast of everything that 3rd party add-ins and custom code does. I worked with a company recently that did everything out of the box and as such had a 3rd party program to make complicated workflows; unfortunately, this program was powerful enough to cause this same infinite loop issue, and unlike your program I seem to recall that this program did not catch stack overflow exceptions until the stack literally did overflow. There were horror stories out there about end users taking the entire server farm down with this program.

  • how to disable event receiver ? – SharePointMan Apr 14 '14 at 6:11
  • If you're an admin, go into the appropriate features section and turn off the feature that activated the event receiver in question. – NotVonKaiser Apr 14 '14 at 6:12
  • One way to disable the event receiver is to call EventFiringEnabled = false ref my link in comment in question. – eirikb Apr 14 '14 at 6:41

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.