I am attempting to follow the tutorial from C# corner about retrieving list history using CSOM and the syntax reads:

Lists.Lists listService = new Lists.Lists();

I get a compile error of:

The type or namespace ‘Lists’ could not be found (are you missing a using directive or an assembly reference?)

I am sure this is very simple and stupid but I can not find it!


That's because the class Lists.Lists does'nt exist. And you can't instanciate the new object of type List, It's the Framwork that gives you the instance

To get a list of your site you will need to do somthing like :

ClientContext ctx = new ClientContext("URL of site ");
List list = ctx.Web.Lists.GetByTitle("Name of your list");

//Now your list is loaded
Console.WriteLine("NB of items : " + list.ItemCount);

Have a look a this link to have some Microsoft Exemple : Complete basic operations using SharePoint client library code

  • Your example is how I have been achieving such. However, I am trying to follow the tutorial here -> why is this done differently? Www.c-sharpcorner.com/UploadFile/safari/sharepoint-2013-retrieve-the-list-item-version-history-and/ – user2676140 Apr 23 '18 at 14:12
  • A yeah, I see. In this tuto, you use only webService asmx of SharePoint (be warn, this API is deprecated by microsoft : Choose the right API set in SharePoint. You should use the SharePoint CSOM (Client SharePoint Object Model) to dev your application – Nico Apr 23 '18 at 14:33
  • 1
    In your tuto, you will need to ADD your webService ( _vit_bin/lists.asmx ) to Visual Studio webService Reference, and discover it. How to: Add a Reference to a Web Service. And after that, Visual Studio will genere the class : Lists.Lists – Nico Apr 23 '18 at 14:36
  • Ah, thank you for the link about being deprecated. What would be the current way to achieve same result? – user2676140 Apr 23 '18 at 14:39
  • You could get the object of type "File" of your item (evry listItem have a File), and get the versions of your file. Have a look at this exemple : How to get list item version history of a custom list using Client Object Model – Nico Apr 23 '18 at 14:46

Alternativly, if you are trying to use the SPOM to get a list, try doing it this way:

using(SPSite spSite = new SPSite(SPContext.Current.Web.Url)) //get site instance
    using(SPWeb spWeb = spSite.OpenWeb()) //get web instance
        SPList spList = spWeb.Lists["YourListName"];  //get List
        SPListItemCollection collection = spList.GetItems();  //get List Items

        foreach(SPListItem item in collection) //loop through List Items
             var title = item["Title"].ToString();//get a List Item title

List.List() is not part of the SharePoint Object Model or the .NET Framework for that matter. If you are using a custom webservice, than you need to install that webservice. Why would you want to use a webservice when you have SPOM and CSOM to get your lists and list data?

  • I am attempting to return versioned data from a rich text field that is set to append text and everything I have tried is not working. I will test you code and get back to you – user2676140 Apr 23 '18 at 20:43

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.