I 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?
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.