question

BenSmith-0861 avatar image
0 Votes"
BenSmith-0861 asked BenSmith-0861 published

Sharepoint client 'List' no extension method 'Items'

I am using the template from the documentation for How to Update List Items on a Sharepoint List using C#. I am using the input rows from a SQL statement source within SSIS.

I have the Microsoft.Sharepoint.Client reference set up. Here is my code

 public override void Input0_ProcessInputRow(Input0Buffer Row)
     {
         string siteUrl = "http://MyServer/sites/MySiteCollection";
    
         ClientContext clientContext = new ClientContext(siteUrl);
         SP.List oList = clientContext.Web.Lists.GetByTitle("Enrollment");
    
         ListItem oListItem = oList.Items.GetById(Row.ID);
    
         oListItem["STATUS"] = Row.Status;
    
         oListItem.Update();
    
         clientContext.ExecuteQuery();
    
     }

But I get the error message on the line ListItem oListItem = oList.Items.GetById(Row.ID);

'List' does not contain a definition for 'Items' and no extension method 'Items' accepting a first argument of type 'List' could be found (are you missing a directive or assembly reference?

I have the namespaces set up correctly

 using Microsoft.SharePoint.Client;
 using SP = Microsoft.SharePoint.Client;


What am I missing?


office-sharepoint-onlinesql-server-integration-servicesoffice-sharepoint-server-development
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

sadomovalex avatar image
1 Vote"
sadomovalex answered BenSmith-0861 published

according to List class members there is no Items property for List class. However there is List.GetItemById method which does what you need - returns list item with specified id. So your code will look like this:

 var oListItem = oList.GetItemById(Row.ID);


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the sharing!

0 Votes 0 ·

That got rid of the error that was showing in the script but at runtime I get the message that its missing the assembly reference file

Could not load file or assembly 'Microsoft.SharePoint.Client, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.

I have the dll for Microsoft.SharePoint.Client in my assembly folder and set up in my references. It doesnt show an error beforehand when the script is in edit mode

0 Votes 0 ·

That got rid of the error that was showing in the script but at runtime I get the message that its missing the assembly reference file

Could not load file or assembly 'Microsoft.SharePoint.Client, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.

I have the dll for Microsoft.SharePoint.Client in my assembly folder and set up in my references. It doesnt show an error beforehand when the script is in edit mode

0 Votes 0 ·