mercredi 4 février 2015

PropertyOrFieldNotInitializedException even if the field is loaded



I am using the below part of code in provider hosted app:



Microsoft.SharePoint.Client.File destinationFile = destinationFolder.Files.Add(fileCreationInfo);
ListItem item = destinationFile.ListItemAllFields;
item["AssignedTo"] = "Test 1";
item.Update();
destinationContext.Load(destinationFile, k => k.ServerRelativeUrl);
destinationContext.ExecuteQuery();

relativeUrl = destinationFile.ServerRelativeUrl;


destinationFolder and destinationContext are already loaded properly. But still I am getting the following error:



The property or field 'ServerRelativeUrl' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.



The weird part is, I am not able to reproduce this error in my dev environment. Can anyone help?








0 commentaires:

Enregistrer un commentaire