Example #1
0
 protected EventProviderBase(System.Guid providerGuid, string providerName)
 {
     if (providerName == null)
     {
         providerName = base.GetType().Name;
     }
     this.m_name     = providerName;
     this.m_guid     = providerGuid;
     this.m_provider = new OverideEventProvider(this);
     try
     {
         this.m_provider.Register(providerGuid);
     }
     catch (ArgumentException)
     {
         this.m_provider = null;
     }
     if (this.m_providerEnabled && !this.m_ETWManifestSent)
     {
         this.SendManifest(this.m_rawManifest, null);
         this.m_ETWManifestSent = true;
     }
     this.m_completelyInited = true;
     EventProviderDataStream.AddProvider(this);
 }
 protected EventProviderBase(System.Guid providerGuid, string providerName)
 {
     if (providerName == null)
     {
         providerName = base.GetType().Name;
     }
     this.m_name = providerName;
     this.m_guid = providerGuid;
     this.m_provider = new OverideEventProvider(this);
     try
     {
         this.m_provider.Register(providerGuid);
     }
     catch (ArgumentException)
     {
         this.m_provider = null;
     }
     if (this.m_providerEnabled && !this.m_ETWManifestSent)
     {
         this.SendManifest(this.m_rawManifest, null);
         this.m_ETWManifestSent = true;
     }
     this.m_completelyInited = true;
     EventProviderDataStream.AddProvider(this);
 }
Example #3
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && (this.m_provider != null))
     {
         this.m_provider.Dispose();
         this.m_provider = null;
     }
 }
        private void Initialize()
        {
            Guid eventSourceGuid;
            string eventSourceName;
            EventDescriptor[] eventDescriptors;
            byte[] manifest;
            GetMetadata(out eventSourceGuid, out eventSourceName, out eventDescriptors, out manifest);

            if (eventSourceGuid.Equals(Guid.Empty))
                throw new ArgumentException(SR.EventSource_NeedGuid);
            if (eventSourceName == null)
                throw new ArgumentException(SR.EventSource_NeedName);
            if (eventDescriptors == null)
                throw new ArgumentException(SR.EventSource_NeedDescriptors);
            if (manifest == null)
                throw new ArgumentException(SR.EventSource_NeedManifest);

            m_name = eventSourceName;
            m_guid = eventSourceGuid;
            m_eventData = eventDescriptors;
            m_rawManifest = manifest;
            m_provider = new OverideEventProvider(this);

            try
            {
                m_provider.Register(eventSourceGuid);
            }
            catch (ArgumentException)
            {
                // Failed to register.  Don't crash the app, just don't write events to ETW.
                m_provider = null;
            }

            if (m_eventSourceEnabled && !m_ETWManifestSent)
            {
                SendManifest(m_rawManifest);
                m_ETWManifestSent = true;
            }


            // Add the curEventSource to the global (weak) list.  This also sets m_id, which is the
            // index in the list. 
            EventListener.AddEventSource(this);

            // We are logically completely initialized at this point.  
            m_completelyInited = true;
        }
Example #5
0
        protected EventProviderBase(Guid providerGuid, string providerName) 
        { 
            if (providerName == null)
                providerName = GetType().Name; 
            m_name = providerName;
            m_guid = providerGuid;
#if ETW_SUPPORTED
            m_provider = new OverideEventProvider(this); 

            try { 
                m_provider.Register(providerGuid); 
            } catch (ArgumentException) {
                // Failed to register.  Don't crash the app, just don't write events to ETW. 
                m_provider = null;
            }

#endif 
            if (m_providerEnabled && !m_ETWManifestSent)
            { 
                SendManifest(m_rawManifest, null); 
                m_ETWManifestSent = true;
            } 
            m_completelyInited = true;
            // Add the provider to the global (weak) list.  This also sets m_id, which is the
            // index in the list.
            EventProviderDataStream.AddProvider(this); 
        }
Example #6
0
        private void Initialize(Guid eventSourceGuid, string eventSourceName)
        {
            if (eventSourceGuid == Guid.Empty)
            {
                throw new ArgumentException(Environment.GetResourceString("EventSource_NeedGuid"));
            }

            if (eventSourceName == null)
            {
                throw new ArgumentException(Environment.GetResourceString("EventSource_NeedName"));
            }

            m_name = eventSourceName;
            m_guid = eventSourceGuid;
#if FEATURE_ACTIVITYSAMPLING
            m_curLiveSessions = new SessionMask(0);
            m_etwSessionIdMap = new EtwSession[SessionMask.MAX];
#endif // FEATURE_ACTIVITYSAMPLING

#if FEATURE_MANAGED_ETW
            m_provider = new OverideEventProvider(this);

            try
            {
                m_provider.Register(eventSourceGuid);
            }
            catch (ArgumentException)
            {
                // Failed to register.  Don't crash the app, just don't write events to ETW.
                m_provider = null;
            }
#endif
            // Add the eventSource to the global (weak) list.  This also sets m_id, which is the
            // index in the list. 
            EventListener.AddEventSource(this);

            // We are logically completely initialized at this point.  
            m_completelyInited = true;

            // report any possible errors
            ReportOutOfBandMessage(null, true);

#if FEATURE_ACTIVITYSAMPLING
            // we cue sending sampling info here based on whether we had to defer sending
            // the manifest
            // note: we do *not* send sampling info to any EventListeners because
            // the following common code pattern would cause an AV:
            // class MyEventSource: EventSource
            // {
            //    public static EventSource Log; 
            // }
            // class MyEventListener: EventListener
            // {
            //    protected override void OnEventWritten(...)
            //    { MyEventSource.Log.anything; } <-- AV, as the static Log was not set yet
            // }
            if (m_eventSourceEnabled && m_deferedSendManifest)
                ReportActivitySamplingInfo(null, m_curLiveSessions);
#endif // FEATURE_ACTIVITYSAMPLING

            // If we are active and we have not sent our manifest, do so now.  
            if (m_eventSourceEnabled && m_deferedSendManifest)
                SendManifest(m_rawManifest);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && (this.m_provider != null))
     {
         this.m_provider.Dispose();
         this.m_provider = null;
     }
 }