you are mising out object from any one of these lines of code, debug using putting breakpiont and share us about the code..
enginecommand.Attributes.Append(stageid);
enginecommand.AppendChild(nameengc);
enginecommand.AppendChild(desengc);
enginecommand.AppendChild(commandengc);
nameengc.AppendChild(nameengctext);
desengc.AppendChild(desengctext);
commandengc.AppendChild(commandengctext);
thanks