public EtwDiagnosticTrace(string traceSourceName, Guid etwProviderId)
            : base(traceSourceName)
        {
            try
            {
                this.TraceSourceName = traceSourceName;
                this.EventSourceName = string.Concat(this.TraceSourceName, " ", EventSourceVersion);
                CreateTraceSource();
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

#pragma warning disable 618
                EventLogger logger = new EventLogger(this.EventSourceName, null);
                logger.LogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToSetupTracing, false,
                                exception.ToString());
#pragma warning restore 618
            }

            try
            {
                CreateEtwProvider(etwProviderId);
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                this.etwProvider = null;
#pragma warning disable 618
                EventLogger logger = new EventLogger(this.EventSourceName, null);
                logger.LogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToSetupTracing, false,
                                exception.ToString());
#pragma warning restore 618
            }

            if (this.TracingEnabled || this.EtwTracingEnabled)
            {
#pragma warning disable 618
                this.AddDomainEventHandlersForCleanup();
#pragma warning restore 618
            }
        }
Esempio n. 2
0
 public EtwDiagnosticTrace(string traceSourceName, Guid etwProviderId) : base(traceSourceName)
 {
     try
     {
         this.TraceSourceName = traceSourceName;
         base.EventSourceName = string.Concat(this.TraceSourceName, " ", "4.0.0.0");
         this.CreateTraceSource();
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         if (!Fx.IsFatal(exception))
         {
             EventLogger eventLogger = new EventLogger(base.EventSourceName, null);
             string[]    str         = new string[1];
             str[0] = exception.ToString();
             eventLogger.LogEvent(TraceEventType.Error, 4, -1073676188, false, str);
         }
         else
         {
             throw;
         }
     }
     try
     {
         this.CreateEtwProvider(etwProviderId);
     }
     catch (Exception exception3)
     {
         Exception exception2 = exception3;
         if (!Fx.IsFatal(exception2))
         {
             this.etwProvider = null;
             EventLogger eventLogger1 = new EventLogger(base.EventSourceName, null);
             string[]    strArrays    = new string[1];
             strArrays[0] = exception2.ToString();
             eventLogger1.LogEvent(TraceEventType.Error, 4, -1073676188, false, strArrays);
         }
         else
         {
             throw;
         }
     }
     if (base.TracingEnabled || this.EtwTracingEnabled)
     {
         base.AddDomainEventHandlersForCleanup();
     }
 }
Esempio n. 3
0
        public void TraceTransfer(Guid newId)
        {
            string empty;
            Guid   activityId = DiagnosticTraceBase.ActivityId;

            if (newId != activityId)
            {
                try
                {
                    if (base.HaveListeners)
                    {
                        base.TraceSource.TraceTransfer(0, null, newId);
                    }
                    if (this.IsEtwEventEnabled(ref EtwDiagnosticTrace.transferEventDescriptor))
                    {
                        EtwProvider        etwProvider            = this.etwProvider;
                        EventDescriptor    eventDescriptorPointer = EtwDiagnosticTrace.transferEventDescriptor;
                        EventTraceActivity eventTraceActivity     = new EventTraceActivity(activityId, false);
                        Guid guid = newId;
                        if (EtwDiagnosticTrace.traceAnnotation == null)
                        {
                            empty = string.Empty;
                        }
                        else
                        {
                            empty = EtwDiagnosticTrace.traceAnnotation();
                        }
                        etwProvider.WriteTransferEvent(eventDescriptorPointer, eventTraceActivity, guid, empty, DiagnosticTraceBase.AppDomainFriendlyName);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    if (!Fx.IsFatal(exception))
                    {
                        base.LogTraceFailure(null, exception);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Esempio n. 4
0
 private void CreateEtwProvider(Guid etwProviderId)
 {
     if (etwProviderId != Guid.Empty && EtwDiagnosticTrace.isVistaOrGreater)
     {
         this.etwProvider = (EtwProvider)EtwDiagnosticTrace.etwProviderCache[(object)etwProviderId];
         if (this.etwProvider == null)
         {
             lock (EtwDiagnosticTrace.etwProviderCache)
             {
                 this.etwProvider = (EtwProvider)EtwDiagnosticTrace.etwProviderCache[(object)etwProviderId];
                 if (this.etwProvider == null)
                 {
                     this.etwProvider = new EtwProvider(etwProviderId);
                     EtwDiagnosticTrace.etwProviderCache.Add(etwProviderId, this.etwProvider);
                 }
             }
         }
         this.etwProviderId = etwProviderId;
     }
 }
        void CreateEtwProvider(Guid etwProviderId)
        {
            if (etwProviderId != Guid.Empty && EtwDiagnosticTrace.isVistaOrGreater)
            {
                //Pick EtwProvider from cache, add to cache if not found
                this.etwProvider = (EtwProvider)etwProviderCache[etwProviderId];
                if (this.etwProvider == null)
                {
                    lock (etwProviderCache)
                    {
                        this.etwProvider = (EtwProvider)etwProviderCache[etwProviderId];
                        if (this.etwProvider == null)
                        {
                            this.etwProvider = new EtwProvider(etwProviderId);
                            etwProviderCache.Add(etwProviderId, this.etwProvider);
                        }
                    }
                }

                this.etwProviderId = etwProviderId;
            }
        }
        public EtwDiagnosticTrace(string traceSourceName, Guid etwProviderId)
            : base(traceSourceName)
        {
            try
            {
                this.TraceSourceName = traceSourceName;
                this.EventSourceName = string.Concat(this.TraceSourceName, " ", EventSourceVersion);
                CreateTraceSource();
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

#pragma warning disable 618
                EventLogger logger = new EventLogger(this.EventSourceName, null);
                logger.LogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToSetupTracing, false,
                    exception.ToString());
#pragma warning restore 618
            }

            try
            {
                CreateEtwProvider(etwProviderId);
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                this.etwProvider = null;
#pragma warning disable 618
                EventLogger logger = new EventLogger(this.EventSourceName, null);
                logger.LogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToSetupTracing, false,
                    exception.ToString());
#pragma warning restore 618

            }

            if (this.TracingEnabled || this.EtwTracingEnabled)
            {
#pragma warning disable 618
                this.AddDomainEventHandlersForCleanup();
#pragma warning restore 618
            }
        }
        void CreateEtwProvider(Guid etwProviderId)
        {
            if (etwProviderId != Guid.Empty && EtwDiagnosticTrace.isVistaOrGreater)
            {
                //Pick EtwProvider from cache, add to cache if not found
                this.etwProvider = (EtwProvider)etwProviderCache[etwProviderId];
                if (this.etwProvider == null)
                {
                    lock (etwProviderCache)
                    {
                        this.etwProvider = (EtwProvider)etwProviderCache[etwProviderId];
                        if (this.etwProvider == null)
                        {
                            this.etwProvider = new EtwProvider(etwProviderId);
                            etwProviderCache.Add(etwProviderId, this.etwProvider);
                        }
                    }
                }

                this.etwProviderId = etwProviderId;
            }
        }
Esempio n. 8
0
		private void CreateEtwProvider(Guid etwProviderId)
		{
			if (etwProviderId != Guid.Empty && EtwDiagnosticTrace.isVistaOrGreater)
			{
				this.etwProvider = (EtwProvider)EtwDiagnosticTrace.etwProviderCache[(object)etwProviderId];
				if (this.etwProvider == null)
				{
					lock (EtwDiagnosticTrace.etwProviderCache)
					{
						this.etwProvider = (EtwProvider)EtwDiagnosticTrace.etwProviderCache[(object)etwProviderId];
						if (this.etwProvider == null)
						{
							this.etwProvider = new EtwProvider(etwProviderId);
							EtwDiagnosticTrace.etwProviderCache.Add(etwProviderId, this.etwProvider);
						}
					}
				}
				this.etwProviderId = etwProviderId;
			}
		}
Esempio n. 9
0
		public EtwDiagnosticTrace(string traceSourceName, Guid etwProviderId) : base(traceSourceName)
		{
			try
			{
				this.TraceSourceName = traceSourceName;
				base.EventSourceName = string.Concat(this.TraceSourceName, " ", "4.0.0.0");
				this.CreateTraceSource();
			}
			catch (Exception exception1)
			{
				Exception exception = exception1;
				if (!Fx.IsFatal(exception))
				{
					EventLogger eventLogger = new EventLogger(base.EventSourceName, null);
					string[] str = new string[1];
					str[0] = exception.ToString();
					eventLogger.LogEvent(TraceEventType.Error, 4, -1073676188, false, str);
				}
				else
				{
					throw;
				}
			}
			try
			{
				this.CreateEtwProvider(etwProviderId);
			}
			catch (Exception exception3)
			{
				Exception exception2 = exception3;
				if (!Fx.IsFatal(exception2))
				{
					this.etwProvider = null;
					EventLogger eventLogger1 = new EventLogger(base.EventSourceName, null);
					string[] strArrays = new string[1];
					strArrays[0] = exception2.ToString();
					eventLogger1.LogEvent(TraceEventType.Error, 4, -1073676188, false, strArrays);
				}
				else
				{
					throw;
				}
			}
			if (base.TracingEnabled || this.EtwTracingEnabled)
			{
				base.AddDomainEventHandlersForCleanup();
			}
		}