I want to get data from SharePoint list by CSOM library on .Net Core MVC application. There are absolutely no problem to achieve that on .Net Framework aplication because Microsoft.SharePoint.Client library contains ExecuteQuery method. Unfortunately .Net Core equivalent not.
I've made Async function
public async Task<ActionResult> GetRequests()
{
ClientContext context = new ClientContext("https://xxx/sites/xxx/");
List certificatesList = context.Web.Lists.GetByTitle("Items");
CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
ListItemCollection items = certificatesList.GetItems(query);
context.Load(items);
Task spTask = context.ExecuteQueryAsync();
await Task.WhenAll(spTask);
var result = items;
...
}
but it seems like it also won't work on .Net Core because it throws
Exception thrown: 'System.InvalidOperationException' in >System.Private.CoreLib.ni.dll
Additional information: Cannot find platform service library. For Windows Store application, please include Microsoft.SharePoint.Client.Runtime.WindowsStore.dll in the application package. For Windows Phone application, please include Microsoft.SharePoint.Client.Runtime.WindowsPhone.dll in the application package. For Windows application, please install Microsoft.SharePoint.Client.Runtime.Windows.dll in the GAC (Global Assembly Cache) or make it available for the Windows application.
Does someone use CSOM in .Net Core or should I use REST Api instead?
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
}
importssection? Or including theMicrosoft.SharePoint.Client.Runtime.WindowsStore.dll(if it targetsportable-net451+win81? Make post your project.json or .csproj if you are on VS2017Microsoft.SharePoint.Client.Runtime.WindowsStoredoesn't help? It's not on nuget, at least no official package, so I can't see the exact targets it supports. But ifMicrosoft.SharePoint.Client.Runtime.WindowsStoredoesn't use any WindowsPhone specific apis (and only targetsportable-net451+81profile, it should still work).portable-net451-win81is a profile for Portable Class libraries which run on desktop and windows mobile/uwp