private ExceptionReportsManager() { backgroundWork = new AbortableBackgroundWorker(); backgroundWork.DoWork += backgroundWork_DoWork; backgroundWork.RunWorkerCompleted += backgroundWork_RunWorkerCompleted; view = new ExceptionReportForm(); view.Closed += view_Closed; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.domain_UnhandledException); Application.ThreadException += new ThreadExceptionEventHandler(this.application_ThreadException); try { IPAddress[] hostAddresses = Dns.GetHostAddresses(Dns.GetHostName()); if (hostAddresses.Length > 0) { this.hostAddress = new string[hostAddresses.Length]; for (int i = 0; i < hostAddresses.Length; i++) { this.hostAddress[i] = hostAddresses[i].ToString(); } } else { this.hostAddress = new string[] { "无本机IP。" }; } } catch { this.hostAddress = new string[] { "获取本机IP失败。" }; } this.config = null; }
/// <summary> /// 获取应用程序配置中名为"exceptionReports"类型为<see cref="ExceptionReportsConfigure"/>的配置节点。 /// </summary> public void LoadConfiguration() { this.config = (ExceptionReportsConfigure)ConfigurationHelper.Load("exceptionReports"); }
/// <summary> /// 配置错误报告。 /// </summary> /// <param name="configuration">错误报告配置信息。</param> public void Config(ExceptionReportsConfigure configuration) { this.config = configuration; }