XML : How can I find the error in value cannot be null

I already I have a c# code the contains an error value cannot be null. 1st try

  if (Global.Publisher != "")          {              opf.Descendants(GetNamespace(ref namespace3, "").GetName("metadata")).Descendants(namespace2 + "publisher").First().Value = Global.Publisher;          }    

2nd try

  if (Global.Publisher != "")              {                  opf.Descendants(GetNamespace(ref namespace3, "").GetName("metadata")).Descendants(namespace2 + "publisher").First().Value = Global.Publisher;              }              else              {                  opf.Descendants(GetNamespace(ref namespace3, "").GetName("metadata")).Descendants(namespace2 + "publisher").First().Value = null;              }    

still i receive an error value cannot be null

No comments:

Post a Comment