Issue1: Invalid data has been used to update the list item. The field you are trying to update may be read only.
Issue2: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
Problem Code:
Issue2: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
Problem Code:
internal static Void GetFileFromTempDocLib(ClientContext clientContext1)
{
var folderRelativeUrl = "";
Web web = clientContext.Web;
clientContext.Load(web, w1
=> w1.ServerRelativeUrl, w1 => w1.Url);
clientContext.ExecuteQuery();
folderRelativeUrl =
web.ServerRelativeUrl;
}
Solution Code:
internal static Void GetFileFromTempDocLib(ClientContext clientContext1)
{
var folderRelativeUrl = "";
Web web = clientContext.Web;
try
{
folderRelativeUrl =
web.ServerRelativeUrl;
}
catch (PropertyOrFieldNotInitializedException ex)
{
clientContext.Load(web, w1
=> w1.ServerRelativeUrl, w1 => w1.Url);
clientContext.ExecuteQuery();
folderRelativeUrl =
web.ServerRelativeUrl;
}
}
No comments:
Post a Comment