【发布时间】:2015-08-27 04:04:35
【问题描述】:
我有以下代码(SharePointUpload 是我拥有的一个自定义类,其中包含一个 Microsoft.SharePoint.Client.File 对象):
private static bool LoadSharePointFile(SharePointUpload fileUpload)
{
ClientContext clientContext = HttpContextManager.SharepointClientContext;
Microsoft.SharePoint.Client.File file = clientContext.Web.GetFileByServerRelativeUrl(fileUpload.FullSharepointPath);
clientContext.Load(file, f => f.CheckOutType, f => f.MajorVersion);
clientContext.ExecuteQuery();
fileUpload.File = file;
}
此方法返回后,我立即访问 CheckOutType 属性,如下所示:
if (fileUpload.File.CheckOutType != CheckOutType.None)
{
...
}
我得到这个错误:
Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException: 属性或字段尚未初始化。它没有被 请求或请求尚未执行。它可能需要 明确要求。 在 Microsoft.SharePoint.Client.ClientObject.CheckUninitializedProperty(字符串 道具名称)
为什么会出现此错误?我在上下文的 Load 方法中定义的那个属性不是已经初始化了吗?
【问题讨论】:
标签: c# sharepoint