for (int i = 0; i < auditList.Count; i++)
{
audit = (XEAudit)auditList[i];
XEEventViewer eventViewer = audit.GetEventViewer();
if (eventViewer != null)
{
while (eventViewer.NextEvent())
{
if ((eventViewer.GetSeverity() == "Normal") || (eventViewer.GetSeverity() == "Critical"))
validationFailed = true;
break;
}
//);
//We assume that there is only one request per call so we will return the
// first data content
if (validationFailed == true)
{
StandardException innerException = traverseDN(OutermostException); ;
OutermostException = innerException;
}
}
//To avoid Resource leak
eventViewer = null;
}
Above is the line of code where in I am trying to resolve the error :
Overwriting eventViewer in "eventViewer = null" leaks the resource that "eventViewer refers to.
I have tried to use eventViewer.Dispose() too after assigning it to null. But not sure why its not helping out.