private bool TryOpenLockQueueForCollection(string subqueueName, out MsmqQueue lockQueue) { lockQueue = null; string formatName = base.formatName + ";" + subqueueName; int accessMode = 1; int shareMode = 1; try { int error = 0; if (MsmqQueue.IsQueueOpenable(formatName, accessMode, shareMode, out error)) { lockQueue = new MsmqQueue(formatName, accessMode, shareMode); lockQueue.EnsureOpen(); } else { if ((error != -1072824311) && (error != -1072824317)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(System.ServiceModel.SR.GetString("MsmqOpenError", new object[] { MsmqError.GetErrorString(error) }), error)); } return(false); } } catch (MsmqException) { return(false); } return(true); }
private bool TryOpenLockQueueForCollection(string subqueueName, out MsmqQueue lockQueue) { lockQueue = null; string formatName = this.formatName + ";" + subqueueName; int accessMode = UnsafeNativeMethods.MQ_RECEIVE_ACCESS; int shareMode = UnsafeNativeMethods.MQ_DENY_RECEIVE_SHARE; try { int error = 0; if (MsmqQueue.IsQueueOpenable(formatName, accessMode, shareMode, out error)) { lockQueue = new MsmqQueue(formatName, accessMode, shareMode); lockQueue.EnsureOpen(); } else { // The lock subqueue is either being actively used by a channel or is not available. // So, we do not have to collect this lock queue. if (error == UnsafeNativeMethods.MQ_ERROR_SHARING_VIOLATION || error == UnsafeNativeMethods.MQ_ERROR_QUEUE_NOT_FOUND) { return(false); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(SR.GetString(SR.MsmqOpenError, MsmqError.GetErrorString(error)), error)); } } } catch (MsmqException) { // The error has already been logged. Since this function is to decide whether to collect // the lock queue, we return false. return(false); } return(true); }