I am debugging on SP2010 environment. There is an Event receiver listening to particular list, the first few lines of code is:
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
SPList listOfEntries = properties.List;
if (listOfEntries.Title == "Command")
I added a breakpoint at the line "SPList listOfEntries = properties.List".
When I added an item to "Command" list manually, the breakpoint will be reached.
There is a SPD list workflow and the workflow create a task asking for approval. If the user reject the task immediately after the task is assigned, a new item will be added to "Command" list by the workflow. In this way, the Event Receiver will not be triggered (the breakpoint will not be reached, too).
I change the VS debugger to monitor OWSTimer and this time breakpoint is reached. On visual studio debug screen I mouseover every variable inside this function. I found all variables are carrying the wrong item! For example,
SPList myList = web.Lists["ListA"];
SPQuery myQuery = new SPQuery();
myQuery.Query = "<Where><Geq><FieldRef Name = \"Title\"/>" + "<Value Type = \"Text\">"
In VS debug mode, "myList" is carrying "ListZ" (which is not within this function). myQuery is carrying web.Lists["ListA"]. All variable goes crazy. That's why my event receiver not work??! Or actually my VS have bug?
If the user wait for 3 minutes before reject the task, the same item will be added to "Command" list by the workflow, the Event Receiver will be triggered this time.
If I check with VS debugger in this situation, all variables show normal value....
It doesn't make sense to me. If my event receiver code have bug, it should at least reach the breakpoint. However it is not fired at all...
Do you have any clue on what is happening?