Пример #1
0
        public static void DumpMemoryTrace(TextWriter writer)
        {
            if (writer == null)
            {
                return;
            }
            bool addHeader = true;

            lock (ExTraceInternal.traceBuilderList)
            {
                writer.WriteLine("ThreadId;ComponentGuid;Instance ID;TraceTag;TraceType;TimeStamp;Message;");
                foreach (WeakReference weakReference in ExTraceInternal.traceBuilderList)
                {
                    MemoryTraceBuilder memoryTraceBuilder = weakReference.Target as MemoryTraceBuilder;
                    if (memoryTraceBuilder != null)
                    {
                        memoryTraceBuilder.Dump(writer, addHeader, true);
                        addHeader = false;
                    }
                }
            }
        }
Пример #2
0
        private void ReportProblem(MemoryTraceBuilder contextTraceBuilder, Exception exception, string functionName, bool isExceptionReport, bool isExceptionReportTerminating, bool verbose)
        {
            using (TempFileStream tempFileStream = TempFileStream.CreateInstance("Traces_", false))
            {
                using (StreamWriter streamWriter = new StreamWriter(tempFileStream))
                {
                    bool addHeader = true;
                    if (contextTraceBuilder != null)
                    {
                        lock (this)
                        {
                            contextTraceBuilder.Dump(streamWriter, addHeader, verbose);
                        }
                        addHeader = false;
                    }
                    MemoryTraceBuilder memoryTraceBuilder = ExTraceInternal.GetMemoryTraceBuilder();
                    if (memoryTraceBuilder != null)
                    {
                        memoryTraceBuilder.Dump(streamWriter, addHeader, verbose);
                    }
                    streamWriter.Flush();
                }
                StringBuilder stringBuilder = new StringBuilder(1024);
                TroubleshootingContext.DumpExceptionInfo(exception, stringBuilder);
                if (TroubleshootingContext.IsTestTopology())
                {
                    string path = ExWatson.AppName + "_" + DateTime.UtcNow.ToString("yyyyMMdd_hhmmss") + ".trace";
                    try
                    {
                        File.Copy(tempFileStream.FilePath, Path.Combine(Path.Combine(Environment.GetEnvironmentVariable("SystemDrive"), "\\dumps"), path));
                    }
                    catch
                    {
                    }
                }
                if (exception != TroubleshootingContext.FaultInjectionInvalidOperationException)
                {
                    if (isExceptionReport)
                    {
                        WatsonExtraFileReportAction watsonExtraFileReportAction = null;
                        try
                        {
                            watsonExtraFileReportAction = new WatsonExtraFileReportAction(tempFileStream.FilePath);
                            ExWatson.RegisterReportAction(watsonExtraFileReportAction, WatsonActionScope.Thread);
                            ExWatson.SendReport(exception, isExceptionReportTerminating ? ReportOptions.ReportTerminateAfterSend : ReportOptions.None, null);
                            goto IL_152;
                        }
                        finally
                        {
                            if (watsonExtraFileReportAction != null)
                            {
                                ExWatson.UnregisterReportAction(watsonExtraFileReportAction, WatsonActionScope.Thread);
                            }
                        }
                    }
                    ExWatson.SendTroubleshootingWatsonReport("15.00.1497.012", this.location, "UnexpectedCondition:" + exception.GetType().Name, exception.StackTrace, functionName, stringBuilder.ToString(), tempFileStream.FilePath);
IL_152:
                    File.Delete(tempFileStream.FilePath);
                }
            }
        }