private static void Initialize(Assembly assembly)
 {
     lock (Instrumentation.instrumentedAssemblies)
     {
         if (!Instrumentation.instrumentedAssemblies.ContainsKey(assembly))
         {
             SchemaNaming schemaNaming = SchemaNaming.GetSchemaNaming(assembly);
             if (schemaNaming != null)
             {
                 if (!schemaNaming.IsAssemblyRegistered())
                 {
                     if (WMICapabilities.IsUserAdmin())
                     {
                         schemaNaming.DecoupledProviderInstanceName = AssemblyNameUtility.UniqueToAssemblyFullVersion(assembly);
                         schemaNaming.RegisterNonAssemblySpecificSchema(null);
                         schemaNaming.RegisterAssemblySpecificSchema();
                     }
                     else
                     {
                         throw new Exception(RC.GetString("ASSEMBLY_NOT_REGISTERED"));
                     }
                 }
                 InstrumentedAssembly instrumentedAssembly = new InstrumentedAssembly(assembly, schemaNaming);
                 Instrumentation.instrumentedAssemblies.Add(assembly, instrumentedAssembly);
             }
         }
     }
 }
Exemple #2
0
        public EventSource(string namespaceName, string appName, InstrumentedAssembly instrumentedAssembly)
        {
            lock (eventSources)
            {
                // This is a pathalogical case where the process is shutting down, but
                // someone wants us to register us as a provider.  In this case, we ignore
                // the request.  This would be problematic if the eventSources list has already
                // been enumerated and all other eventSources unregistered.  If we were allowed
                // to register a new event source, it would never be unregistered
                if (shutdownInProgress != 0)
                {
                    return;
                }

                this.instrumentedAssembly = instrumentedAssembly;
                int hr = registrar.Register_(0, null, null, null, namespaceName, appName, this);

                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                // If we've gotten here, we were successful with the Register call
                eventSources.Add(this);
            }
        }
Exemple #3
0
        private static void Initialize(Assembly assembly)
        {
            lock (instrumentedAssemblies)
            {
                if (instrumentedAssemblies.ContainsKey(assembly))
                {
                    return;
                }

                SchemaNaming naming = SchemaNaming.GetSchemaNaming(assembly);
                if (naming == null)
                {
                    return;
                }

                if (false == naming.IsAssemblyRegistered())
                {
                    // If we are not an administrator, don't try to JIT install the schema
                    if (!WMICapabilities.IsUserAdmin())
                    {
                        throw new Exception(RC.GetString("ASSEMBLY_NOT_REGISTERED"));
                    }

                    naming.RegisterNonAssemblySpecificSchema(null);
                    naming.RegisterAssemblySpecificSchema();
                }

                InstrumentedAssembly instrumentedAssembly = new InstrumentedAssembly(assembly, naming);
                instrumentedAssemblies.Add(assembly, instrumentedAssembly);
            }
        }
Exemple #4
0
 public EventSource(string namespaceName, string appName, InstrumentedAssembly instrumentedAssembly)
 {
     lock (eventSources)
     {
         if (shutdownInProgress == 0)
         {
             this.instrumentedAssembly = instrumentedAssembly;
             int errorCode = this.registrar.Register_(0, null, null, null, namespaceName, appName, this);
             if (errorCode != 0)
             {
                 Marshal.ThrowExceptionForHR(errorCode);
             }
             eventSources.Add(this);
         }
     }
 }
 public EventSource(string namespaceName, string appName, InstrumentedAssembly instrumentedAssembly)
 {
     lock (eventSources)
     {
         if (shutdownInProgress == 0)
         {
             this.instrumentedAssembly = instrumentedAssembly;
             int errorCode = this.registrar.Register_(0, null, null, null, namespaceName, appName, this);
             if (errorCode != 0)
             {
                 Marshal.ThrowExceptionForHR(errorCode);
             }
             eventSources.Add(this);
         }
     }
 }
Exemple #6
0
		public EventSource(string namespaceName, string appName, InstrumentedAssembly instrumentedAssembly)
		{
			this.registrar = (IWbemDecoupledRegistrar)(new WbemDecoupledRegistrar());
			this.reqList = new ArrayList(3);
			this.critSec = new object();
			this.doIndicate = new AutoResetEvent(false);
			this.alive = true;
			this.mapQueryIdToQuery = new Hashtable();
			lock (EventSource.eventSources)
			{
				if (EventSource.shutdownInProgress == 0)
				{
					this.instrumentedAssembly = instrumentedAssembly;
					int num = this.registrar.Register_(0, null, null, null, namespaceName, appName, this);
					if (num != 0)
					{
						Marshal.ThrowExceptionForHR(num);
					}
					EventSource.eventSources.Add(this);
				}
			}
		}
Exemple #7
0
 public EventSource(string namespaceName, string appName, InstrumentedAssembly instrumentedAssembly)
 {
     this.registrar         = (IWbemDecoupledRegistrar)(new WbemDecoupledRegistrar());
     this.reqList           = new ArrayList(3);
     this.critSec           = new object();
     this.doIndicate        = new AutoResetEvent(false);
     this.alive             = true;
     this.mapQueryIdToQuery = new Hashtable();
     lock (EventSource.eventSources)
     {
         if (EventSource.shutdownInProgress == 0)
         {
             this.instrumentedAssembly = instrumentedAssembly;
             int num = this.registrar.Register_(0, null, null, null, namespaceName, appName, this);
             if (num != 0)
             {
                 Marshal.ThrowExceptionForHR(num);
             }
             EventSource.eventSources.Add(this);
         }
     }
 }
        private static void Initialize(Assembly assembly)
        {
            if (instrumentedAssemblies.ContainsKey(assembly))
            {
                return;
            }

            SchemaNaming naming = SchemaNaming.GetSchemaNaming(assembly);

            if (naming == null)
            {
                return;
            }

            if (false == naming.IsAssemblyRegistered())
            {
                throw new Exception("This assembly has not been registered with WMI");
            }

            InstrumentedAssembly instrumentedAssembly = new InstrumentedAssembly(assembly, naming);

            instrumentedAssemblies.Add(assembly, instrumentedAssembly);
        }
Exemple #9
0
        private static void Initialize(Assembly assembly)
        {
            lock (instrumentedAssemblies)
            {
                if (instrumentedAssemblies.ContainsKey(assembly))
                {
                    return;
                }

                SchemaNaming naming = SchemaNaming.GetSchemaNaming(assembly);
                if (naming == null)
                {
                    return;
                }

                if (false == naming.IsAssemblyRegistered())
                {
                    // If we are not an administrator, don't try to JIT install the schema
                    if (!WMICapabilities.IsUserAdmin())
                    {
                        throw new Exception(RC.GetString("ASSEMBLY_NOT_REGISTERED"));
                    }

                    //
                    // We always use the full version number for Whidbey.
                    //
                    naming.DecoupledProviderInstanceName = AssemblyNameUtility.UniqueToAssemblyFullVersion(assembly);

                    naming.RegisterNonAssemblySpecificSchema(null);
                    naming.RegisterAssemblySpecificSchema();
                }

                InstrumentedAssembly instrumentedAssembly = new InstrumentedAssembly(assembly, naming);
                instrumentedAssemblies.Add(assembly, instrumentedAssembly);
            }
        }
Exemple #10
0
        private void InitEventSource(object param)
        {
            InstrumentedAssembly threadParam = (InstrumentedAssembly)param;

            threadParam.source = new EventSource(threadParam.naming.NamespaceName, threadParam.naming.DecoupledProviderInstanceName, this);
        }
Exemple #11
0
        private void InitEventSource(object param)
        {
            InstrumentedAssembly eventSource = (InstrumentedAssembly)param;

            eventSource.source = new EventSource(eventSource.naming.NamespaceName, eventSource.naming.DecoupledProviderInstanceName, this);
        }
        public EventSource(string namespaceName, string appName, InstrumentedAssembly instrumentedAssembly)
        {
            lock(eventSources)
            {
                // This is a pathalogical case where the process is shutting down, but
                // someone wants us to register us as a provider.  In this case, we ignore
                // the request.  This would be problematic if the eventSources list has already
                // been enumerated and all other eventSources unregistered.  If we were allowed
                // to register a new event source, it would never be unregistered
                if(shutdownInProgress != 0)
                    return;

                this.instrumentedAssembly = instrumentedAssembly;
             int hr = registrar.Register_(0, null, null, null, namespaceName, appName, this);

                if(hr != 0)
                    Marshal.ThrowExceptionForHR(hr);

                // If we've gotten here, we were successful with the Register call
                eventSources.Add(this);
            }
        }
Exemple #13
0
        private static void Initialize(Assembly assembly)
        {
            lock(instrumentedAssemblies)
            {
                if(instrumentedAssemblies.ContainsKey(assembly))
                    return;

                SchemaNaming naming = SchemaNaming.GetSchemaNaming(assembly);
                if(naming == null)
                    return;

                if(false == naming.IsAssemblyRegistered())
                {
                    // If we are not an administrator, don't try to JIT install the schema
                    if(!WMICapabilities.IsUserAdmin())
                        throw new Exception(RC.GetString("ASSEMBLY_NOT_REGISTERED"));

			//
			// We always use the full version number for Whidbey.
			//
			naming.DecoupledProviderInstanceName = AssemblyNameUtility.UniqueToAssemblyFullVersion(assembly);

                    naming.RegisterNonAssemblySpecificSchema(null);
                    naming.RegisterAssemblySpecificSchema();
                }

                InstrumentedAssembly instrumentedAssembly = new InstrumentedAssembly(assembly, naming);
                instrumentedAssemblies.Add(assembly, instrumentedAssembly);
            }
        }
Exemple #14
0
		private static void Initialize(Assembly assembly)
		{
			lock (Instrumentation.instrumentedAssemblies)
			{
				if (!Instrumentation.instrumentedAssemblies.ContainsKey(assembly))
				{
					SchemaNaming schemaNaming = SchemaNaming.GetSchemaNaming(assembly);
					if (schemaNaming != null)
					{
						if (!schemaNaming.IsAssemblyRegistered())
						{
							if (WMICapabilities.IsUserAdmin())
							{
								schemaNaming.DecoupledProviderInstanceName = AssemblyNameUtility.UniqueToAssemblyFullVersion(assembly);
								schemaNaming.RegisterNonAssemblySpecificSchema(null);
								schemaNaming.RegisterAssemblySpecificSchema();
							}
							else
							{
								throw new Exception(RC.GetString("ASSEMBLY_NOT_REGISTERED"));
							}
						}
						InstrumentedAssembly instrumentedAssembly = new InstrumentedAssembly(assembly, schemaNaming);
						Instrumentation.instrumentedAssemblies.Add(assembly, instrumentedAssembly);
					}
				}
			}
		}