示例#1
0
        static PSETWTracerFactory()
        {
            PSETWTracerFactory.tracerAvailable = PSETWTracerFactory.IsTracerSupportedOnOS();
            if (!PSETWTracerFactory.tracerAvailable)
            {
                return;
            }
            Assembly assembly = (Assembly)null;

            try
            {
                assembly = Assembly.LoadFrom(PSETWTracerFactory.assemblyFile);
            }
            catch (ArgumentNullException ex)
            {
            }
            catch (FileNotFoundException ex)
            {
            }
            catch (FileLoadException ex)
            {
            }
            catch (BadImageFormatException ex)
            {
            }
            catch (SecurityException ex)
            {
            }
            catch (ArgumentException ex)
            {
            }
            catch (PathTooLongException ex)
            {
            }
            if (assembly == null)
            {
                return;
            }
            PSETWTracerFactory.tracerLoader = (IETWTracerLoader)assembly.GetType("System.Management.Automation.Internal.PSETWTracerLoader").GetMethod("GetInstance").Invoke((object)null, (object[])null);
        }
示例#2
0
 private void HandleClientRemoteSessionStateChanged(object sender, RemoteSessionStateEventArgs e)
 {
     using (ClientRunspacePoolDataStructureHandler.tracer.TraceMethod())
     {
         if (e.SessionStateInfo.State == RemoteSessionState.NegotiationSending)
         {
             if (this.createRunspaceCalled)
             {
                 return;
             }
             lock (this.syncObject)
             {
                 if (this.createRunspaceCalled)
                 {
                     return;
                 }
                 this.createRunspaceCalled = true;
             }
             this.SendDataAsync(RemotingEncoder.GenerateCreateRunspacePool(this.clientRunspacePoolId, this.minRunspaces, this.maxRunspaces, this.remoteSession.RemoteRunspacePoolInternal, this.host, PSPrimitiveDictionary.CloneAndAddPSVersionTable(this.applicationArguments)));
         }
         else if (e.SessionStateInfo.State == RemoteSessionState.ClosingConnection)
         {
             Exception exception = this.closingReason;
             if (exception == null)
             {
                 exception          = e.SessionStateInfo.Reason;
                 this.closingReason = exception;
             }
             lock (this.associationSyncObject)
             {
                 foreach (ClientPowerShellDataStructureHandler structureHandler in this.associatedPowerShellDSHandlers.Values)
                 {
                     structureHandler.CloseConnection();
                 }
             }
             if (this.SessionClosing == null)
             {
                 return;
             }
             this.SessionClosing((object)this, new RemoteDataEventArgs <Exception>((object)exception));
         }
         else if (e.SessionStateInfo.State == RemoteSessionState.Closed)
         {
             Exception reason = this.closingReason;
             if (reason == null)
             {
                 reason             = e.SessionStateInfo.Reason;
                 this.closingReason = reason;
             }
             if (reason != null)
             {
                 this.NotifyAssociatedPowerShells(new RunspacePoolStateInfo(RunspacePoolState.Broken, reason));
             }
             else
             {
                 this.NotifyAssociatedPowerShells(new RunspacePoolStateInfo(RunspacePoolState.Closed, reason));
             }
             if (this.SessionClosed == null)
             {
                 return;
             }
             this.SessionClosed((object)this, new RemoteDataEventArgs <Exception>((object)reason));
         }
         else if (e.SessionStateInfo.State == RemoteSessionState.Connected)
         {
             using (IETWTracer etwTracer = PSETWTracerFactory.GetETWTracer(PSKeyword.Runspace))
                 etwTracer.ReplaceActivityIdForCurrentThread(this.clientRunspacePoolId, PSEventId.OperationalTransferEventRunspacePool, PSEventId.AnalyticTransferEventRunspacePool, PSKeyword.Runspace, PSTask.CreateRunspace);
         }
         else
         {
             if (e.SessionStateInfo.Reason == null)
             {
                 return;
             }
             this.closingReason = e.SessionStateInfo.Reason;
         }
     }
 }