I am getting this error and from what I understand this is when you try and access columns from the list item. I have tried various things including the line below:

clientContext.Load(items, eachItem => eachItem.Include(item => item,item => item["Name"]));

I started off using this code. All of these resulted in the same error message:

The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested

Here is my code that I'm currently using just to try and work out what is going on. The list I'm trying to access is a standard Picture Library, and I just need to the access the Name of the image so I can construct a url to the image.

        string server = "http://myserver/path/path";
        var context = new ClientContext(server);
        var web = context.Web;
        var list = web.Lists.GetByTitle("Photos");
        var listItemCollection = list.GetItems(CamlQuery.CreateAllItemsQuery());



        foreach (ListItem listItem in listItemCollection)
            Console.WriteLine(listItem.FieldValuesAsText["Name"]); // Also tried listItem.DisplayName and File.Name

Try this:


If you want to work with the DisplayName, you should do it like this:

ctx.Load(listItemCollection, items => items.IncludeWithDefaultProperties(item => item.DisplayName));

The following link should help you out: http://blogs.technet.com/b/speschka/archive/2009/11/01/using-the-sharepoint-2010-client-object-model-part-2.aspx

  • I actually started off with this one and I had the same problem from what I remember. Will try again when back on my dev machine. Thanks
    – Andrew
    Aug 6 '12 at 8:15
  • Should Title just be available without passing anything additional to .load()?
    – Andrew
    Aug 6 '12 at 18:49
  • 1
    Yes that's right. Have a look here: msdn.microsoft.com/en-us/library/ee534956.aspx Aug 6 '12 at 19:09
  • So I can now return a full list with DisplayName, But as soon as I introduce a simple camlquery to filter on the DisplayName I get back to the same error as before.. query to follow. I have tried with and without viewfields
    – Andrew
    Aug 6 '12 at 20:06
  • query.ViewXml = "<View><Query><Where><Eq><FieldRef Name='DisplayName'/>" + "<Value Type='Text'>" + contactId + "</Value></Eq></Where></Query>" + "<ViewFields>" + "<FieldRef Name='DisplayName' />" + "</ViewFields></View>";
    – Andrew
    Aug 6 '12 at 20:07

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.