Null Object Exception when build running


If the build is running and the app runs an update then because there is no FinishDate the attempt to create a new Build object fails, the code below fixes this by checking for 'null' before passing a FinishDate into the Build object (see final element in build object construction):-
        return new Build
                Number = xElementBuild.Attribute("number").Value,
                Status = xElementBuild.Attribute("status").Value.Equals("success", StringComparison.OrdinalIgnoreCase) ? Status.Success : Status.Fail,
                StatusText = xElementBuild.Element("statusText").Value,
                UniqueIdentifier = xElementBuildType.Attribute("id").Value,
                TypeName = xElementBuildType.Attribute("name").Value,
                ProjectName = xElementBuildType.Attribute("projectName").Value,

                StartDate = DateTime.ParseExact(xElementBuild.Element("startDate").Value, "yyyyMMddTHHmmsszzzz", CultureInfo.InvariantCulture),
                FinishDate = (xElementBuild.Element("finishDate") == null) ? DateTime.Now : DateTime.ParseExact(xElementBuild.Element("finishDate").Value, "yyyyMMddTHHmmsszzzz", CultureInfo.InvariantCulture),