每当我运行我的项目时,我在最后一行“对象引用未设置为对象的实例”时收到错误我已经搜索过它,我得到的是我正在尝试使用null对象。我知道它为什么它是null但是因为一旦我放置一个断点并将鼠标悬停在变量“title”上它就有一个值。 这是一些代码。我基本上将XML数据存储到sharepoint站点的变量中。
if (node.ChildNodes[f].Name == "z:row")
{
try
{
title = node.ChildNodes[f].Attributes["ows_Request_x0020_ID"].Value;
assignedTo = node.ChildNodes[f].Attributes["ows_Request_x0020_Name"].Value;
//comments = node.ChildNodes[f].Attributes["ows_Development_x0020_Phase"].Value;
comments = "rrrr";
status = " something";
openDate = "OpenDate";
closeDate = "";
if (node.ChildNodes[f].Attributes["ows_Est_x002e__x0020_Dev_x0020_Compl"] != null)
{
closeDate = node.ChildNodes[f].Attributes["ows_Est_x002e__x0020_Dev_x0020_Compl"].Value;
}
spTable.Columns.AddRange(spColumns);
sprow = spTable.NewRow();
sprow[0] = title;
sprow[1] = assignedTo;
sprow[2] = comments;
sprow[3] = status;
sprow[4] = openDate;
sprow[5] = closeDate;
spTable.Rows.Add(sprow);
}
catch (Exception j)
{
sprow = spTable.NewRow();
//Error is in the line below
title = node.ChildNodes[f].Attributes["ows_Request_x0020_ID"].Value;