title: "The handle is invalid" execption recevied while creating the object of MQ Queue Manager
body: <p>Please find the below code:</p>
  
  <pre><code>MQEnvironment.Hostname = HostName;
          MQEnvironment.Channel = Channel;
  
          if (!string.IsNullOrEmpty(SSLKeyRepository))
          {
              MQEnvironment.SSLCipherSpec = SSLCipherSpec;
              MQEnvironment.SSLKeyRepository = SSLKeyRepository;
          }
          if (Port &gt; 0)
              MQEnvironment.Port = Port;
  
          try
          {
              MQManager = new MQQueueManager(QueueManager);
              try
              {
                  MQRequestQueue = MQManager.AccessQueue(QueueNameGet, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
                  MQResponseQueue = MQManager.AccessQueue(QueueNameGet, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);                     
                  return true;
              }
              catch (IBM.WMQ.MQException exIBM)
              {
                  CloseConnection();
                  ErrorCode = exIBM.Reason;
                  ErrorDescription = exIBM.Message;
                                  }
          }
          catch (IBM.WMQ.MQException exIBM)
          {
              CloseConnection();
              ErrorCode = exIBM.Reason;
              ErrorDescription = exIBM.Message;
          }
          catch (Exception ex)
          {
              CloseConnection();
              ErrorCode = Constants.SYSTEMEXCEPTION;
              ErrorDescription = ex.Message;
          }
          return false;
  </code></pre>
  
  <p>Issue: I am not getting the issue when I run it for single or 2-3 times. But I get the issue when it runs in a loop for multiple times.
  Also, I have tried to run the same piece of code for 10,000 times from the IIS server and it ran successfully.</p>
  
  <p>I am getting the issue only when I have this code on IIS webservice and that webservice is getting called multiple times. </p>
  
  <p>IBM MQ client 7.5.0.0 installed on the IIS server and I am using the dll of the same version.</p>
  
  <p><strong>UPDATE</strong>
  Error description:</p>
  
  <p>Error Message  The handle is invalid<br>
      StackTrace     at     System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)     at System.Diagnostics.Process.get_Modules()     at IBM.WMQ.CommonServices.TraceEnvironment()     at IBM.WMQ.CommonServices.CreateCommonServices()     at IBM.WMQ.CommonServices.TraceEnabled()     at IBM.WMQ.MQBase..ctor()     at IBM.WMQ.MQManagedObject..ctor()</p>