SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm facing strange problem. I have following code to get last item workflow and its task item.

var wfCol = item.Workflows;
if ((wfCol == null) || (wfCol.Count == 0))
    return null;
var wfItem = wfCol[0];

// this condition is never true when not in debug
if ((wfItem.TaskList != null) && (wfItem.Tasks.Count > 0)) {

I can never go inside the condition, because wfItem.TaskList is null and wfItem.Tasks throws Object reference not set to an instance of an object.

However, when I use debug and add breakpoint before wfItem.TaskList is called, it will go inside the condition. I have found out that when in VS I disable Property evalution(Tools -> Options -> Debugger -> Enable property evalution) it behaves just like without breakpoint.

Is there any option to force Sharepoint to do the same like Debugger does property evalution?

Thank you

share|improve this question
up vote 0 down vote accepted

So here is a nasty hack :-/ I am not proud of it, but it is working. I just called

var tmp1 = wfItem.TaskList;


var tmp2 = wfItem.Tasks.Count;

before I really need those properties. So they get loaded and condition is finally correctly evaluated

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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