Im having some troubles when i try to retrieve data from a list in sharepoint 2013.
SPSite osite = new SPSite(@"http://contoso.com"); SPWeb web = osite.OpenWeb(); SPList list = web.Lists["Calendar"]; SPListItemCollection collection = list.Items; foreach (SPListItem item in collection) { Console.WriteLine(item["Title"]); }
And im getting this error: System.InvalidOperationException: Exception of type 'System.InvalidOperationException' was thrown.
I did a research in MSDN and i could connect to a diferent list in SharePoint 2010 using Visual Studio 2010, but now im using Visual Studio 2012 to connect to SharePoint 2013 and i dont get the same result.
Im using the DLL Microsoft.SharePoint. 15.0.0.0
Thanks!