在.Net核心应用程序中使用SharePoint CSOM

在.Net核心应用程序中使用SharePoint CSOM,.net,sharepoint,asp.net-core,.net,Sharepoint,Asp.net Core,我想通过.Net核心MVC应用程序上的CSOM库从SharePoint列表中获取数据。在.Net Framework应用程序上实现这一点绝对没有问题,因为Microsoft.SharePoint.Client库包含ExecuteQuery方法。不幸的是,与.Net核心相当的不是 我已经创建了异步函数 public async Task<ActionResult> GetRequests() { ClientContext context = new Clien

我想通过.Net核心MVC应用程序上的CSOM库从SharePoint列表中获取数据。在.Net Framework应用程序上实现这一点绝对没有问题,因为Microsoft.SharePoint.Client库包含ExecuteQuery方法。不幸的是,与.Net核心相当的不是

我已经创建了异步函数

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;
        ...

    }

我有这个问题。出于某种原因,当您引用Microsoft.SharePointOnline.CSOM nuget包时,它使用了.net framework DLL,而不是netcore45 DLL。 以下是我为解决这个问题所做的工作:

  • 下载nuget软件包
  • 将其解压缩到项目中的子文件夹中,例如;依赖关系
  • 参考正确的组件

    netcore45\Microsoft.SharePoint.Client.Portable.dll netcore45\Microsoft.SharePoint.Client.Runtime.Portable.dll net45\Microsoft.SharePoint.Client.Runtime.Windows.dll netcore45\Microsoft.SharePoint.Client.Runtime.WindowsStore.dll


  • 哦,如果你已经有了nuget软件包,那么就在上面安装一个卸载软件包。

    如果它支持.NET标准,我会更加惊讶。你做了一些。。。。project.json中的“funky”东西,比如玩/滥用
    imports
    部分?或者包括
    Microsoft.SharePoint.Client.Runtime.WindowsStore.dll
    (如果它的目标是
    portable-net451+win81
    ?如果您在VS2017I上,请发布您的project.json或.csproj我已附加project.json“导入”问题是.Net核心应用程序上的Microsoft.SharePoint.Client引用与.Net Framework应用程序上的Microsoft.SharePoint.Client引用大不相同。所有dll都类似,但都包含“可移植的”在名称中,所以我没有Microsoft.SharePoint.Client.Runtime.dll,但有Microsoft.SharePoint.Client.Runtime.Portable.dllAnd添加
    Microsoft.SharePoint.Client.Runtime.WindowsStore
    没有帮助?它不在nuget上,至少没有官方软件包,所以我看不到它支持的确切目标。但是如果
    Microsoft.SharePoint.Client.Runtime.WindowsStore
    不使用任何特定于WindowsPhone的API(并且只针对
    portable-net451+81
    profile,它应该仍然可以工作)。
    portable-net451-win81
    是运行在桌面和windows mobile/uwp上的portable类库的配置文件
      "frameworks": {
        "netcoreapp1.0": {
          "imports": [
            "dotnet5.6",
            "portable-net45+win8"
          ]
        }
      }