예제 #1
0
        public ClientInfo Initialize()
        {
            _monitor = OperationContext.Current.GetCallbackChannel <IDebugMonitor>();
            var communicationObject = (_monitor as ICommunicationObject);

            communicationObject.Closing += OnShutdown;
            communicationObject.Faulted += OnShutdown;
            if (Loader.IsLogging)
            {
                EnableLogging();
            }
            LoggingTraceListener.LogEntryAdded           += OnLogEntryAdded;
            AppDomain.CurrentDomain.FirstChanceException += OnFirstChanceException;
            AppDomain.CurrentDomain.UnhandledException   += OnUnhandledException;

            using (var process = Process.GetCurrentProcess())
            {
                return(new ClientInfo()
                {
                    ProcessId = process.Id,
                    ProcessName = process.ProcessName,
                    ProcessLocation = process.StartInfo.FileName,
                    DomainId = AppDomain.CurrentDomain.Id,
                    DomainName = AppDomain.CurrentDomain.FriendlyName,
                    MachineName = Environment.MachineName,
                    IsX64Process = Environment.Is64BitProcess
                });
            }
        }
예제 #2
0
        private void OnShutdown(object sender, EventArgs e)
        {
            if (Loader.IsLogging)
            {
                DisableLogging();
            }
            LoggingTraceListener.LogEntryAdded           -= OnLogEntryAdded;
            AppDomain.CurrentDomain.FirstChanceException -= OnFirstChanceException;
            AppDomain.CurrentDomain.UnhandledException   -= OnUnhandledException;
            _monitor = null;
            _entriesToSend.CompleteAdding();

            foreach (var plugIn in PlugIns.ToArray())
            {
                plugIn.OnDetach();
                PlugIns.Remove(plugIn);
            }
        }