protected override PSProperty DoGetProperty(ManagementBaseObject wmiObject, string propertyName) { PropertyData adapterData = null; // First check whether we have any Class properties by this name PSProperty returnValue = base.DoGetProperty(wmiObject, propertyName); if (returnValue != null) { return(returnValue); } try { adapterData = wmiObject.Properties[propertyName]; return(new PSProperty(adapterData.Name, this, wmiObject, adapterData)); } catch (ManagementException) { } catch (Exception e) { CommandProcessorBase.CheckForSevereException(e); // TODO: Bug 251457. This is a workaround to unblock partners and find out the root cause. Tracing.PSEtwLogProvider provider = new Tracing.PSEtwLogProvider(); provider.WriteEvent(PSEventId.Engine_Health, PSChannel.Analytic, PSOpcode.Exception, PSLevel.Informational, PSTask.None, PSKeyword.UseAlwaysOperational, string.Format(CultureInfo.InvariantCulture, "ManagementBaseObjectAdapter::DoGetProperty::PropertyName:{0}, Exception:{1}, StackTrace:{2}", propertyName, e.Message, e.StackTrace), string.Empty, string.Empty); // ignore the exception. } return(null); }
private static Collection<LogProvider> CreateLogProvider(string shellId) { Collection<LogProvider> collection = new Collection<LogProvider>(); try { LogProvider item = new EventLogLogProvider(shellId); collection.Add(item); item = new PSEtwLogProvider(); collection.Add(item); return collection; } catch (ArgumentException) { } catch (InvalidOperationException) { } catch (SecurityException) { } collection.Add(new DummyLogProvider()); return collection; }
/// <summary> /// Class constructor /// </summary> static PSEtwLog() { provider = new PSEtwLogProvider(); }
/// <summary> /// Create a log provider based on a shell Id. /// </summary> /// <param name="shellId"></param> /// <returns></returns> private static Collection<LogProvider> CreateLogProvider(string shellId) { #if V2 try { Assembly crimsonAssembly = Assembly.Load(_crimsonLogProviderAssemblyName); if (crimsonAssembly != null) { LogProvider logProvider = (LogProvider)crimsonAssembly.CreateInstance(_crimsonLogProviderTypeName, false, // don't ignore case BindingFlags.CreateInstance, null, // use default binder null, null, // use current culture null // no special activation attributes ); System.Diagnostics.Debug.Assert(logProvider != null); return logProvider; } } catch (FileNotFoundException e) { _trace.TraceException(e); } catch (BadImageFormatException e) { _trace.TraceException(e); } catch (SecurityException e) { _trace.TraceException(e); } catch (TargetInvocationException e) { _trace.TraceException(e); } #endif Collection<LogProvider> providers = new Collection<LogProvider>(); // Porting note: Linux does not support ETW #if !UNIX try { #if !CORECLR //TODO:CORECLR EventLogLogProvider not handled yet LogProvider eventLogLogProvider = new EventLogLogProvider(shellId); providers.Add(eventLogLogProvider); #endif LogProvider etwLogProvider = new PSEtwLogProvider(); providers.Add(etwLogProvider); return providers; } catch (ArgumentException) { } catch (InvalidOperationException) { } catch (SecurityException) { // This exception will happen if we try to create an event source // (corresponding to the current running minishell) // when running as non-admin user. In that case, we will default // to dummy log. } #endif providers.Add(new DummyLogProvider()); return providers; }