- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 c# 中的 .NET CSOM 在线获取 Sharepoint 上文件的父列表。当我从独立的 C# 应用程序测试下面的代码时,它工作正常。
但是当我通过 C++ 中的 com 互操作调用完全相同的方法时,使用相同的参数,我得到一个异常,“指定的对象不属于列表”。 ExecuteQuery() 后抛出异常
但我知道它确实如此,如果我使用完全相同的 URL /sites/develop_apps/Shared Documents/subway/heynow(000640-9-9-2016 9-53-31 AM).PDF 调用该方法
在独立的 c# 应用程序中,我也不异常(exception)。而“GetFileByServerRelativeUrl”似乎工作正常。无论如何它都不会抛出异常。
我读过有关类似错误的文章,它们似乎与网址有关。但我不明白为什么相同的参数在一种情况下有效,但在另一种情况下却无效。
Microsoft.SharePoint.Client.File thisFile =m_clientContext.Web.GetFileByServerRelativeUrl(fileRelativeUrl);
ListItem item = thisFile.ListItemAllFields;
m_clientContext.Load(item.ParentList);
m_clientContext.ExecuteQuery();
错误的 Fiddler 跟踪显示。
{"SchemaVersion":"15.0.0.0","LibraryVersion":"16.0.5701.1202","ErrorInfo":{"ErrorMessage":"The object specified does not belong to alist.","ErrorValue":null,"TraceCorrelationId":"c616a29d-90ab-3000-b1de-17538058f3e4","ErrorCode":-2146232832,"ErrorTypeName":"Microsoft.SharePoint.SPException"},"TraceCorrelationId":"c616a29d-90ab-3000-b1de-17538058f3e4"
最佳答案
通过比较工作应用程序和失败的生产测试的 ClientContext.Url 字段,我注意到 url 是不同的。
我正在运行的测试的 url 为“https://mysite.sharepoint.com/sites/develop_apps/”。
我的生产测试未通过其“https://mysite.sharepoint.com”
我在“https://mysite.sharepoint.com/sites/develop_apps/”的库中进行所有列表操作
我想在对列表进行处理时,您需要在创建关于 url 的 clientContext 时更加具体。
关于sharepoint-online - 使用 CSOM 时出现 "The object specified does not belong to a list"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39413728/
我是一名优秀的程序员,十分优秀!