コード例 #1
0
ファイル: Misc.cs プロジェクト: dox0/DotNet471RS3
        internal static void WriteUnhandledExceptionToEventLog(AppDomain appDomain, Exception exception)
        {
            if (appDomain == null || exception == null)
            {
                return;
            }

            ProcessImpersonationContext imperContext = null;

            try {
                imperContext = new ProcessImpersonationContext();
                String appId = appDomain.GetData(".appId") as String;
                if (appId == null)
                {
                    appId = appDomain.FriendlyName;
                }
                string pid         = SafeNativeMethods.GetCurrentProcessId().ToString(CultureInfo.InstalledUICulture);
                string description = SR.Resources.GetString(SR.Unhandled_Exception, CultureInfo.InstalledUICulture);
                Misc.ReportUnhandledException(exception, new string[5] {
                    description, APPLICATION_ID, appId, PROCESS_ID, pid
                });
            }
            catch {
                // ignore exceptions so that WriteErrorToEventLog never throws
            }
            finally {
                if (imperContext != null)
                {
                    imperContext.Undo();
                }
            }
        }
コード例 #2
0
ファイル: Misc.cs プロジェクト: iskiselev/JSIL.NetFramework
        internal static void WriteUnhandledExceptionToEventLog(AppDomain appDomain, Exception exception) {
            if (appDomain == null || exception == null) {
                return;
            }

            ProcessImpersonationContext imperContext = null;
            try {
                imperContext = new ProcessImpersonationContext();
                String appId = appDomain.GetData(".appId") as String;
                if (appId == null) {
                    appId = appDomain.FriendlyName;
                }
                string pid = SafeNativeMethods.GetCurrentProcessId().ToString(CultureInfo.InstalledUICulture);
                string description = SR.Resources.GetString(SR.Unhandled_Exception, CultureInfo.InstalledUICulture);
                Misc.ReportUnhandledException(exception, new string[5] {description, APPLICATION_ID, appId, PROCESS_ID, pid});
            }
            catch {
                // ignore exceptions so that WriteErrorToEventLog never throws
            }
            finally {
                if (imperContext != null) {
                    imperContext.Undo();
                }
            }
        }
コード例 #3
0
 internal static void WriteUnhandledExceptionToEventLog(AppDomain appDomain, Exception exception)
 {
     if ((appDomain != null) && (exception != null))
     {
         ProcessImpersonationContext context = null;
         try
         {
             context = new ProcessImpersonationContext();
             string data = appDomain.GetData(".appId") as string;
             if (data == null)
             {
                 data = appDomain.FriendlyName;
             }
             string str2 = System.Web.SafeNativeMethods.GetCurrentProcessId().ToString(CultureInfo.InstalledUICulture);
             string str3 = System.Web.SR.Resources.GetString("Unhandled_Exception", CultureInfo.InstalledUICulture);
             ReportUnhandledException(exception, new string[] { str3, "\r\n\r\nApplication ID: ", data, "\r\n\r\nProcess ID: ", str2 });
         }
         catch
         {
         }
         finally
         {
             if (context != null)
             {
                 context.Undo();
             }
         }
     }
 }
コード例 #4
0
            private WebEventProvider GetProviderInstance(string providerName)
            {
                object obj2 = this._instances[providerName];

                if (obj2 == null)
                {
                    return(null);
                }
                ProviderSettings settings = obj2 as ProviderSettings;

                if (settings != null)
                {
                    WebEventProvider provider;
                    Type             c = BuildManager.GetType(settings.Type, false);
                    if (typeof(IInternalWebEventProvider).IsAssignableFrom(c))
                    {
                        provider = (WebEventProvider)HttpRuntime.CreateNonPublicInstance(c);
                    }
                    else
                    {
                        provider = (WebEventProvider)HttpRuntime.CreatePublicInstance(c);
                    }
                    ProcessImpersonationContext context = new ProcessImpersonationContext();
                    try
                    {
                        provider.Initialize(settings.Name, settings.Parameters);
                    }
                    catch (ConfigurationErrorsException)
                    {
                        throw;
                    }
                    catch (ConfigurationException exception)
                    {
                        throw new ConfigurationErrorsException(exception.Message, settings.ElementInformation.Properties["type"].Source, settings.ElementInformation.Properties["type"].LineNumber);
                    }
                    catch
                    {
                        throw;
                    }
                    finally
                    {
                        if (context != null)
                        {
                            ((IDisposable)context).Dispose();
                        }
                    }
                    this._instances[providerName] = provider;
                    return(provider);
                }
                return(obj2 as WebEventProvider);
            }
コード例 #5
0
        internal static void RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, int index0, int index1)
        {
            bool flag  = false;
            bool flag2 = false;
            ProcessImpersonationContext context = null;
            HttpContext current = HttpContext.Current;
            object      data    = CallContext.GetData("_WEvtRIP");

            if ((data == null) || !((bool)data))
            {
                eventRaised.IncrementPerfCounters();
                eventRaised.IncrementTotalCounters(index0, index1);
                if (firingRuleInfos == null)
                {
                    firingRuleInfos = HealthMonitoringManager.Manager()._sectionHelper.FindFiringRuleInfos(eventRaised.GetType(), eventRaised.EventCode);
                }
                if (firingRuleInfos.Count != 0)
                {
                    try
                    {
                        bool[] flagArray = null;
                        if (EtwTrace.IsTraceEnabled(5, 1) && (current != null))
                        {
                            EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_START, current.WorkerRequest, eventRaised.GetType().FullName, eventRaised.EventCode.ToString(CultureInfo.InstalledUICulture), eventRaised.EventDetailCode.ToString(CultureInfo.InstalledUICulture), null);
                        }
                        try
                        {
                            foreach (HealthMonitoringSectionHelper.FiringRuleInfo info in firingRuleInfos)
                            {
                                HealthMonitoringSectionHelper.RuleInfo info2 = info._ruleInfo;
                                if (info2._ruleFiringRecord.CheckAndUpdate(eventRaised) && (info2._referencedProvider != null))
                                {
                                    if (!flag)
                                    {
                                        eventRaised.PreProcessEventInit();
                                        flag = true;
                                    }
                                    if (info._indexOfFirstRuleInfoWithSameProvider != -1)
                                    {
                                        if (flagArray == null)
                                        {
                                            flagArray = new bool[firingRuleInfos.Count];
                                        }
                                        if (flagArray[info._indexOfFirstRuleInfoWithSameProvider])
                                        {
                                            continue;
                                        }
                                        flagArray[info._indexOfFirstRuleInfoWithSameProvider] = true;
                                    }
                                    if (EtwTrace.IsTraceEnabled(5, 1) && (current != null))
                                    {
                                        EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_START, current.WorkerRequest, info2._ruleSettings.Provider, info2._ruleSettings.Name, info2._ruleSettings.EventName, null);
                                    }
                                    try
                                    {
                                        if (context == null)
                                        {
                                            context = new ProcessImpersonationContext();
                                        }
                                        if (!flag2)
                                        {
                                            CallContext.SetData("_WEvtRIP", true);
                                            flag2 = true;
                                        }
                                        info2._referencedProvider.ProcessEvent(eventRaised);
                                    }
                                    catch (Exception exception)
                                    {
                                        try
                                        {
                                            info2._referencedProvider.LogException(exception);
                                        }
                                        catch
                                        {
                                        }
                                    }
                                    finally
                                    {
                                        if (EtwTrace.IsTraceEnabled(5, 1) && (current != null))
                                        {
                                            EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_DELIVER_END, current.WorkerRequest);
                                        }
                                    }
                                }
                            }
                        }
                        finally
                        {
                            if (context != null)
                            {
                                context.Undo();
                            }
                            if (flag2)
                            {
                                CallContext.FreeNamedDataSlot("_WEvtRIP");
                            }
                            if (EtwTrace.IsTraceEnabled(5, 1) && (current != null))
                            {
                                EtwTrace.Trace(EtwTraceType.ETW_TYPE_WEB_EVENT_RAISE_END, current.WorkerRequest);
                            }
                        }
                    }
                    catch
                    {
                        throw;
                    }
                }
            }
        }