I got following error...
System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.SPListItem.get_UniqueId() at ConsoleApplication1.Program.Main(String[] args) in Program.cs:line 21
running following code
using (SPSite site = new SPSite("http://site/"))
{
using (SPWeb web = site.OpenWeb())
{
try
{
SPList list = web.Lists["ListName"]; // 2
SPListItem item = list.Items.Add();
Guid itemId = item.UniqueId;
SPListItem itemUpdate = web.Lists["ListName"].Items[itemId];
itemUpdate["PercentComplete"] = .45; // 45%
itemUpdate.Update();
}
catch (Exception e)
{
Console.WriteLine(e);
Console.ReadLine();
}
}
}
What's the problem?